how to resolve this error “com.android.internal.telephony cannot be resolved to a type” in android

风格不统一 提交于 2019-11-27 08:09:22
ρяσѕρєя K

you have added ITelephony.AIDL file in your project? and if you have added then your package name must be com/android/internal/telephony/ITelephony.AIDL: for more information Blocking Incoming call. download AIDL file from here

You can use reflection to call methods on the ITelephony object thus avoiding the need to specify the type and add the AIDL file. For instance, ending a call:

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
Object telephonyService = m.invoke(tm);
Class<?> telephonyServiceClass = Class.forName(telephonyService.getClass().getName());
Method endCallMethod = telephonyServiceClass.getDeclaredMethod("endCall");
endCallMethod.invoke(telephonyService);

You're using internal/hidden Android API's with reflection.

Check that you're trying to invoke a valid method name - there's a great chance that this API has changed or does not exists in the version you're developing for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!