开发者

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


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜