itelephony.aidl answerringingcall()不工作 [英] itelephony.aidl answerringingcall() doesn't work

查看:2032
本文介绍了itelephony.aidl answerringingcall()不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中使用ITelephony.aidl。使用此我想接听来电。我设法使用结束呼叫()和它完美的作品。但是,当我尝试使用answerringingcall()它抛出的错误,并表示,MODIFY_PHONE_STATE是必要的,但由于它仅适用于系统应用程序不能被使用。

那么,有没有做对Android 2.3及以上这项工作的方法吗?或者是有应答呼叫任何其他方式?

在此先感谢:)

这是我的code。

`

 公共无效callAnswer(){
        尝试{
            C类=的Class.forName(telephony.getClass()的getName());
            方法M = c.getDeclaredMethod(getITelephony);
            m.setAccessible(真);
            telephonyService =(ITelephony)m.invoke(电话);
            telephonyService.answerRingingCall();
        }赶上(RemoteException的E){
            // TODO自动生成catch块
            e.printStackTrace();
        }
    }`

这是我ITelephony.aidl文件

 包com.android.internal.telephony;
接口ITelephony { 布尔结束呼叫(); 无效answerRingingCall();
}


解决方案

必须添加许可使用许可权的android:NAME =android.permission.MODIFY_PHONE_STATE

I am trying to use ITelephony.aidl in my application. Using this i want to answer the incoming call. I managed to use endcall() and it works perfectly. But when i try to use answerringingcall() it throws error and says that MODIFY_PHONE_STATE is needed, but cant be used since its only available for system apps.

So is there any way of making this work on android 2.3 and above?or is there any other way for answering calls ?

thanks in advance:)

here's my code.

`

public void callAnswer(){


        try {
            Class c = Class.forName(telephony.getClass().getName());
            Method m = c.getDeclaredMethod("getITelephony");
            m.setAccessible(true);
            telephonyService = (ITelephony) m.invoke(telephony);
            telephonyService.answerRingingCall();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }`

and this is my ITelephony.aidl file

 package com.android.internal.telephony;
interface ITelephony {

 boolean endCall();

 void answerRingingCall();


}

解决方案

must add permission uses-permission android:name="android.permission.MODIFY_PHONE_STATE"

这篇关于itelephony.aidl answerringingcall()不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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