Using android internal API's and getting null value
<p>I am using com.android.internal.telephony classes, They are Call.java, CallManager.java and Connetion.java. For these classes click on below links. <a href="http://hi-android.info/src/com/android/internal/telephony/Call.java.html" rel="nofollow">Call.java</a>, <a href="http://hi-android.info/src/com/android/internal/telephony/CallManager.java.html" rel="nofollow">CallManager.java</a> and <a href="http://hi-android.info/src/com/android/internal/telephony/Connection.java.html" rel="nofollow">Connection.java</a>. I created subclasses for Call.java and Connection.java like as follows :   </p>

<pre><code> Call call = new MyCall();
 Connection conn = new MyConnection();
</code></pre>

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

<pre><code>public class MyCall extends Call{   

CallManager cm = CallManager.getInstance();
MyCall fgCall;
 private final ArrayList&lt;Connection&gt; emptyConnections = new ArrayList&lt;Connection&gt;();

@Override
public List&lt;Connection&gt; getConnections() {      

    fgCall = (MyCall) cm.getActiveFgCall();
    System.out.println("**inside getConnections="+fgCall);
    if ( fgCall != null) {
        return fgCall.getConnections();
    }
    return emptyConnections;

}

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

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

}

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

public Connection getEarliestConnection() {
    List l;
    long time = Long.MAX_VALUE;
    Connection c;
    Connection earliest = null;

    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;
}

}
</code></pre>

<p>I called CallManager.java is as follows:</p>

<pre><code>CallManager cm = CallManager.getInstance();  
</code></pre>

<p>Bcoz this is an 'final' modifier class I called like this.
My another class is CallUpdate.java. In this class I called getEarliestConnection() and DisconnectCause methods of Call and Connection classes respectively. Is as follows:  </p>

<pre><code> public Object getCallFailedString(){
         myConn = myCall.getEarliestConnection();
          System.out.println("myConn is  ******"+myConn);
          System.out.println("myCall is  ******"+myCall);   
         if(myConn == null){
           System.out.println("myConn is null ******");
               return null;
           }                
          else {
                 Connection.DisconnectCause cause = myConn.getDisconnectCause();                           System.out.println("myconn is not null ******"+cause);
                }
</code></pre>

<p>But I am getting connection is null i.e only If part is getting executed not else part. For this I called getActivefgCall from CallManger like this:   </p>

<pre><code>public List&lt;Connection&gt; getConnections() {      
               fgCall = (MyCall) cm.getActiveFgCall();
                 System.out.println("**inside getConnections="+fgCall);
                 if ( fgCall != null) {
                           return fgCall.getConnections();
                        }
                  return emptyConnections;
                }
</code></pre>

<p>But still I am getting null value of FgCall and same in <code>getCallFailedString</code> method also. I want to get execute else part of <code>getCallFailedString</code> method. How to resolve this problem help me. 
Thx in advance</p>
