Getting Call value is null
<p>In my code I am getting a value of Call is null. i.e I am using three internal API's they are Call.java</p>

<p><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></p>

<p>CallManger.java</p>

<p><a href="http://hi-android.info/src/com/android/internal/telephony/CallManager.java.html" rel="nofollow">http://hi-android.info/src/com/android/internal/telephony/CallManager.java.html</a> and </p>

<p>Connection.java</p>

<p><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>.</p>

<p>I created subclass for Call and connection class. </p>

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

    CallManager cm = CallManager.getInstance(); 
    Phone.State state;
    Connection c;
     Phone mDefaultPhone;
     private final ArrayList&lt;Connection&gt; emptyConnections = new ArrayList&lt;Connection&gt;();    


     Call ringingCall;

    @Override
    public List&lt;Connection&gt; getConnections() {              
        System.out.println("before if****"+ringingCall);
    if(ringingCall != null){                
        System.out.println("inside if****");
        ringingCall = (Call) cm.getForegroundCalls();
        System.out.println("**call is not null***");
        System.out.println("value of call"+ringingCall);
        return ((Call) ringingCall).getConnections();
    }           
            else
             {
                 System.out.println("**list is  null***");
                 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() {
        System.out.println("inside EarliestConnection"); 
        List l;
        long time = Long.MAX_VALUE;
        Connection c;
        Connection earliest = null;

        l = getConnections();
        System.out.println("value of connection is=="+l); 
        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 CallManger like this :</p>

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

<p>My another class is CallUpdate . It should give me a OutgoingCall States(i.e states of other end phone is Busy, power-off or not-reachable) .</p>

<pre><code>public class CallUpdate {   

    Call myCall = new MyCall();
    Connection myConn = new MyConnection();
    CallManager cm = CallManager.getInstance();

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


                switch(cause){

                 case BUSY :
                   System.out.println("inside busy");
                 break;

                 case NUMBER_UNREACHABLE :
                    System.out.println("inside un-reachable");
                 break;

                case POWER_OFF :
                   System.out.println("inside power off");
                 break;  
              }     


        }
    return myConn;
 }

}
</code></pre>

<p>But I am getting Call value is null in the above method of Call.java.</p>

<p>Call ringingCall</p>

<pre><code>    public List&lt;Connection&gt; getConnections() {              
     System.out.println("before if****"+ringingCall);
    if(ringingCall != null){                
    System.out.println("inside if****");
    ringingCall = (Call) cm.getForegroundCalls();
    System.out.println("**call is not null***");
    System.out.println("value of call"+ringingCall);
    return ((Call) ringingCall).getConnections();
}           
        else
         {
             System.out.println("**list is  null***");
             return emptyConnections;
    }   
    }
</code></pre>

<p>The rigingCall values is null. Why this value is null? Is I am doing in correct way ?. plz help me</p>

<p>Thx in advance.</p>
