傻狗123 2016-04-02 06:29 采纳率: 0%
浏览 2058
已结题

通过aidl 实现打电话功能 报错

错误信息

 04-02 11:42:52.816: E/AndroidRuntime(25387): FATAL EXCEPTION: main
04-02 11:42:52.816: E/AndroidRuntime(25387): Process: com.example.call, PID: 25387
04-02 11:42:52.816: E/AndroidRuntime(25387): java.lang.NoSuchMethodError: No interface method call(Ljava/lang/String;)V in class Lcom/android/internal/telephony/ITelephony; or its super classes (declaration of 'com.android.internal.telephony.ITelephony' appears in /system/framework/framework.jar:classes2.dex)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at com.example.call.MainActivity.onCreate(MainActivity.java:37)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.Activity.performCreate(Activity.java:6100)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.ActivityThread.access$800(ActivityThread.java:178)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.os.Handler.dispatchMessage(Handler.java:111)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.os.Looper.loop(Looper.java:194)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at android.app.ActivityThread.main(ActivityThread.java:5643)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at java.lang.reflect.Method.invoke(Native Method)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at java.lang.reflect.Method.invoke(Method.java:372)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
04-02 11:42:52.816: E/AndroidRuntime(25387):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  • 写回答

3条回答

  • 傻狗123 2016-04-02 06:33
    关注

    再此加上文件目录

    图片说明

    MainActivity代码

     package com.example.call;
    
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    
    import com.android.internal.telephony.ITelephony;
    
    import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.os.IBinder;
    import android.os.RemoteException;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;
    
    public class MainActivity extends Activity {
    
        private Method method;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            //通过反射机制得到类
    
            try {
                //得到类
                Class clazz = Class.forName("android.os.ServiceManager");
                //得到方法
                method = clazz.getMethod("getService", String.class);
                //调用方法(静态方法不用传对象)
                IBinder iBinder = (IBinder) method.invoke(null, Context.TELEPHONY_SERVICE);
                //得到远程服务接口
                ITelephony telePhone = ITelephony.Stub.asInterface(iBinder);
                //打电话功能
                telePhone.call("15686207622");
            } catch (ClassNotFoundException e) {
                //没有找到这个类
                Log.i("123", "没有找到这个类");
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                // 没有找到这个方法
                Log.i("123", "没有找到这个方法");
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // 方法调用失败
                Log.i("123", "方法调用失败");
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // 方法调用失败
                Log.i("123", "方法调用失败");
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // 方法调用失败
                Log.i("123", "方法调用失败");
                e.printStackTrace();
            } catch (RemoteException e) {
                // 拨打电话失败
                Log.i("123", "拨打电话失败");
                e.printStackTrace();
            }
    
        }
    
    
    }
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗