Getting null value
<p>I am using com.android.internal.telephony API's. In that I called two abstract classes they are Call.java and Connection.java. You can find these classes here <a href="http://hi-android.info/src/com/android/internal/telephony/Call.java.html" rel="nofollow">http://hi-android.info/src/com/android/internal/telephony/Call.java.html</a> and <a href="http://hi-android.info/src/com/android/internal/telephony/Connection.java.html" rel="nofollow">http://hi-android.info/src/com/android/internal/telephony/Connection.java.html</a> for these created subclasses like</p>

<pre><code>Call myCall = new MyCall();
Connection myConn = new MyConnection();
</code></pre>

<p>I need to use getDisconnectCause method from connection class which is an abstract method, I used like this:</p>

<pre><code>myConn = myCall.getEarliestConnection();                            
      if(myConn == null){
         System.out.println("myConn is null ******");   
        }else
           {
            Connection.DisconnectCause cause = myConn.getDisconnectCause();                      
                System.out.println("value of cause ******"+cause);  
           }
</code></pre>

<p>The subclass of Call.java is:</p>

<pre><code>1.     CallManager cm = CallManager.getInstance();  
2.        Phone.State state;
3.    
4.        public List&lt;Connection&gt; getConnections() {    
5.         state = cm.getState();       
6.         ringingCall = cm.getForegroundCalls();    
7.         System.out.println("**inside getConnections="+state);    
8.         System.out.println("**inside getConnections="+ringingCall);  
9.           if ( ringingCall == null) {
10.               System.out.println("**call is null***");
11.               return emptyConnections;
12.            }
13.            else
14.            {
15.             System.out.println("**call is not null***");
16.                    return ((Call) ringingCall).getConnections();    
17.            }
18.                    @Override
19.                    public Phone getPhone() {
20.                     return null;
                    }
                   @Override
                   public void hangup() throws CallStateException {

                            }

                   @Override
                   public boolean isMultiparty() {
                    return false;
                   }        
                   public Connection
                       getEarliestConnection() {
                            List l;
                                long time = Long.MAX_VALUE;
                                Connection c;
                                Connection earliest = null;

     68.                        l = getConnections();

                                if (l == null) {
                                    return null;
                                }else if ( l.size() == 0)
                                {
                                    return null;
                                }

                                for (int i = 0, s = l.size() ; i &lt; s ; i++) {
                                    c = (Connection) l.get(i);
                                    long t;

                                    t = c.getCreateTime();

                                    if (t &lt; time) {
                                        earliest = c;
                                        time = t;
                                    }
                                }

                                return earliest;
                            }

                        }

AND the Connection.java subclass is:


    class MyConnection extends Connection{

            @Override
            public void cancelPostDial() {
                // TODO Auto-generated method stub

            }

            @Override
            public String getAddress() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Call getCall() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public long getConnectTime() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public long getCreateTime() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public DisconnectCause getDisconnectCause() {
                // TODO Auto-generated method stub


                return null;
            }

            @Override
            public long getDisconnectTime() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public long getDurationMillis() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public long getHoldDurationMillis() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public int getNumberPresentation() {
                // TODO Auto-generated method stub
                return 0;
            }

            @Override
            public PostDialState getPostDialState() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public String getRemainingPostDialString() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public UUSInfo getUUSInfo() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void hangup() throws CallStateException {
                // TODO Auto-generated method stub

            }

            @Override
            public boolean isIncoming() {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void proceedAfterWaitChar() {
                // TODO Auto-generated method stub

            }

            @Override
            public void proceedAfterWildChar(String arg0) {
                // TODO Auto-generated method stub

            }

            @Override
            public void separate() throws CallStateException {
                // TODO Auto-generated method stub

            } 


        }  
</code></pre>

<p><code>EDIT 2 : I have edited line number 1 to 17. Plz check this. I am getting java.lang.ClassCastException: java.util.Collections error on Line No: 16 and Line No:68.</code> Can anybody help me to resolve this. And also I am getting only one state of call i.e IDLE always even though the call is not-null . I am getting inside else part. plz help me.</p>
