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
- Download the ITelephony.aidl from android source repository.
- Rename the ITelephony.aidl to ITelephony.java
- put this file in your project src directory as /src/android/internal/telephony/ITelephony.java
It will work.
精彩评论