android: iTelephony
<p>I am working on Android 2.2/2.3 and need to use some of the api's provided by iTelephony. </p>

<p>I have tried few ways to access some of the hidden APIs but it doesn't work. </p>

<p>Please let me know if anyone has attempt successfully or any suggestions are welcome.</p>

<blockquote>
  <p>Exception encountered: WARN/System.err(827): java.lang.NoSuchMethodException: getActiveCallsCount</p>
</blockquote>

<p>Eg. <code>getActiveCallsCount(); getHoldCallsCount(); getCallTime() etc...</code></p>

<p>Here is my sample code :</p>

<pre><code>private void getActiveCallCounts() {
        try {
            Class serviceManagerClass = Class.forName("android.os.ServiceManager");
            Method getServiceMethod = serviceManagerClass.getMethod("getService", String.class);
            Object phoneService = getServiceMethod.invoke(null, "phone");

            Class ITelephonyClass = Class.forName("com.android.internal.telephony.ITelephony");
            Class ITelephonyStubClass = null;
            for (Class clazz : ITelephonyClass.getDeclaredClasses()) {
                if (clazz.getSimpleName().equals("Stub")) {
                    ITelephonyStubClass = clazz;
                    break;
                }
            }
            if (ITelephonyStubClass != null) {
                Class IBinderClass = Class.forName("android.os.IBinder");
                Method asInterfaceMethod = ITelephonyStubClass.getDeclaredMethod("asInterface", IBinderClass);
                Object iTelephony = asInterfaceMethod.invoke(null, phoneService);
                if (iTelephony != null) {
                    Method getActiveCallsCountMethod = iTelephony.getClass().getMethod("getActiveCallsCount");                      
                    Integer output= getActiveCallsCountMethod.invoke(iTelephony);        
                    System.out.println("got call count.. " + output.intValue()); 
                } else {
                    Log.w("TTT", "Telephony service is null, can't call "
                            + "getActiveCallsCount");
                }
            } else {
                Log.d("TTT", "Unable to locate ITelephony.Stub class!");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            Log.e("TTT", "Failed to get active call count due to Exception!" + ex.getMessage());
        } 

    }
</code></pre>
