Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:32:19+00:00 2026-05-28T03:32:19+00:00

I am doing one android application, for that I used com.android.internal API’s. They are

  • 0

I am doing one android application, for that I used com.android.internal API’s. They are Call.java, CallManger.java. For these classes I created subclass for Call.java. You can find these two classes here http://hi-android.info/src/com/android/internal/telephony/Call.java.html and http://hi-android.info/src/com/android/internal/telephony/CallManager.java.html.

Subclass of Call.java is:

public class MyCall extends Call{

 1.     CallManager cm = CallManager.getInstance(); 
 2.     Phone.State state;
 3.     
 4.      Phone mDefaultPhone;
 5.      private final ArrayList<Connection> emptyConnections = new ArrayList<Connection>();    
 6.      List<Call> ringingCall;
 7.     
 8.     @Override
 9.     public List<Connection> getConnections() {      
 10.        
 11.        
 12.        state = cm.getState();      
 13.        ringingCall = cm.getForegroundCalls();     
 14.        System.out.println("**inside getConnections="+state);   
 15.        System.out.println("**inside getConnections="+ringingCall); 
 16.        if ( ringingCall == null) {
 17.            
 18.            System.out.println("**call is null***");
 19.            return emptyConnections;
 20.         }
 21.         else
 22.         {
 23.            System.out.println("**call is not null***");
 24.            return ((Call) ringingCall).getConnections();   
            }


        }

        @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 < s ; i++) {
                c = (Connection) l.get(i);
                long t;

                t = c.getCreateTime();

                if (t < time) {
                    earliest = c;
                    time = t;
                }
            }

            return earliest;
        }
    }

I called instance of CallManger Like this:

 CallManager cm = CallManager.getInstance();

Bcoz this is a final modifier class. My another class is CallUpdate.java.

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

I am getting myConn value is null. For this I added some piece of code in getConnection method of MyCall class to get a non-null value of myConn. i.e

 state = cm.getState();     
        ringingCall = cm.getForegroundCalls();     
        System.out.println("**inside getConnections="+state);   
        System.out.println("**inside getConnections="+ringingCall); 
        if ( ringingCall == null) {

            System.out.println("**call is null***");
            return emptyConnections;
        }
        else
        {
            System.out.println("**call is not null***");
            return ((Call) ringingCall).getConnections();   
        }

But it is throwing ClassCastException error on Line No:24 and on line
l = getConnections();.
And also I need at least one outgoing call to get a value of myConn. How to resolve this error?

Thx in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:32:20+00:00Added an answer on May 28, 2026 at 3:32 am

    ringingCall is a List<Call> – not a single call. You probably want something like:

    if (ringingCall != null && !ringingCall.isEmpty()) {
        Call call = ringingCall.get(0);
        // Use call
    }
    

    … but you should also consider what you want to do if there’s more than one call.

    In general, if you find yourself casting that’s because you think you know better than the compiler. It should always at least make you think – and in the case where you want a Call but you’ve got a List<Call>, the natural approach should be to use an element from the list.

    It’s not clear whether you really want to be subclassing Call in the first place, to be honest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing one application in android for that I need to access com.android.internal.telephony
Been doing some Android permission research and ran across an application that - according
i am doing one small application , wheich have login functionality, in the user
Some people have suggested that when doing an estimate one should make a lower
I have a android application, that uses many images. and application is to be
I have an Android application with a main activity that is the tabhost. I'm
I have a Button that I am using 13 times in my Android application's
I was looking at a tutorial, this one to be exact - http://android-er.blogspot.com/2011/01/start-camera-auto-focusing-autofocus.html And
I'm creating an android application and within it there is a button that will
I've developed an android-application that I'dd like to put up on the marketplace. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.