如何解决此错误“com.android.internal.telephony 无法解析为类型"在安卓中 [英] how to resolve this error "com.android.internal.telephony cannot be resolved to a type" in android

查看:24
本文介绍了如何解决此错误“com.android.internal.telephony 无法解析为类型"在安卓中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建简单的呼叫过滤器应用程序来限制不需要的呼叫.我使用以下代码来限制呼叫,但我无法解决以下代码中这一行的问题"com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm); "它显示错误消息 com.android.internal.telephony 无法解析为 android 中的类型如何解决此错误.

i am creating simple call filter application which restrict unwanted calls. i use following code to restrict call but i am unable to resole problem of this line in below code " com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm); " it show the error message com.android.internal.telephony cannot be resolved to a type in android how to resolve this error .

public class CallBlockReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub

    }

    private void getTeleService(Context context) {
        TelephonyManager tm = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        try {
            // Java reflection to gain access to TelephonyManager's
            // ITelephony getter
            Log.v("", "Get getTeleService...");
            Class c = Class.forName(tm.getClass().getName());
            Method m = c.getDeclaredMethod("getITelephony");
            m.setAccessible(true);
            com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm);
        } catch (Exception e) {
            e.printStackTrace();
            Log.e("",
                    "FATAL ERROR: could not connect to telephony subsystem");
            Log.e("", "Exception object: " + e);
        }
}

}

请帮帮我.

推荐答案

您在项目中添加了 ITelephony.AIDL 文件吗?如果您已添加,那么您的包名称必须为 com/android/internal/telephony/ITelephony.AIDL:有关更多信息阻止来电.从 这里

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

这篇关于如何解决此错误“com.android.internal.telephony 无法解析为类型"在安卓中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆