android_dev
android_dev

Reputation: 537

Problem with rejecting incoming call

I try to reject incoming call bu this code:

    private void ignoreCallAidl(Context context) 
{
        try
        {
                tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                Class c = Class.forName(tm.getClass().getName());
                Method m = c.getDeclaredMethod("getITelephony");
                m.setAccessible(true);
                telephonyService = (ITelephony)m.invoke(tm);
                telephonyService.silenceRinger();
                telephonyService.endCall();

        } 
        catch (Exception e) 
        {
                e.printStackTrace();
                Log.e("App","FATAL ERROR: could not connect to telephony subsystem");
                Log.e("App","Exception object: "+e);
        }
}

But i get an error: Exception object: java.lang.ClassCastException: com.android.internal.telephony.ITelephony$Stub$Proxy

Upvotes: 2

Views: 6008

Answers (3)

Ton
Ton

Reputation: 9736

-keep class com.android.internal.telephony.ITelephony { *; }

Upvotes: 3

AgilePro
AgilePro

Reputation: 11

Follow these steps

  1. Download the ITelephony.aidl from android source repository.
  2. Rename the ITelephony.aidl to ITelephony.java
  3. put this file in your project src directory as /src/android/internal/telephony/ITelephony.java

It will work.

Upvotes: 1

lovekara0417
lovekara0417

Reputation: 41

I had the same problem, but I have solved it.

It's because you have proguarded the ITelephony from ITelephony.aidl. You have to filter it in the proguard.cfg file.

Upvotes: 4

Related Questions