Android reject incoming call

空扰寡人 提交于 2019-12-20 07:29:27

问题


In my android project(with target sdk version 23), I want reject incoming call. I know that there are a lot of question about this, in particular

1 How to import com.android.internal.telephony.ITelephony to the Android application

2 How to Reject a call programatically in android

3 How to reject any incoming call when I have already detected it

In the first one link, the suggest solution is use reflection on the interface ITelephony because it's an internal interface. But this solution use MODIFY_PHONE_STATE permission, which can only be granted to system apps so it won't work anyway.

From second and third link, I understand that solution is copy ITelephony from here then put it in a new package of com.android.internal.telephony in my solution. The problem is that in this interface there are a lot of problem about find of class android.telephony.RadioAccessFamily (error cannot find symbol class RadioAccessFamily), that class is in platform framework base of android.

Any idea for resolve this problem?


回答1:


I found the answer myself. For others interested, here here it is:

create aidl folder in main folder.

create package com.android.internal.telephony in aidl folder

create a aidl file in package:

interface ITelephony {      

    boolean endCall(); 
    void answerRingingCall();      

}

for the code about end call see the answer in the link.

and it's not necessary add the permission

android.permission.MODIFY_PHONE_STATE



来源:https://stackoverflow.com/questions/34226282/android-reject-incoming-call

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