简体   繁体   English

Android拒绝来电

[英]Android reject incoming call

In my android project(with target sdk version 23), I want reject incoming call. 在我的android项目(目标SDK版本23)中,我想拒绝来电。 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 1 如何将com.android.internal.telephony.ITelephony导入Android应用程序

2 How to Reject a call programatically in android 2 如何在Android中以编程方式拒绝通话

3 How to reject any incoming call when I have already detected it 3 当我已经检测到来电时如何拒绝来电

In the first one link, the suggest solution is use reflection on the interface ITelephony because it's an internal interface. 在第一个链接中,建议的解决方案是在接口ITelephony上使用反射,因为它是内部接口。 But this solution use MODIFY_PHONE_STATE permission, which can only be granted to system apps so it won't work anyway. 但是此解决方案使用MODIFY_PHONE_STATE权限,该权限只能授予系统应用程序,因此无论如何都无法使用。

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. 从第二个和第三个链接,我知道解决方案是从此处复制ITelephony ,然后将其放在我的解决方案中的com.android.internal.telephony新程序包中。 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 . 问题是,在此接口中,存在有关查找类android.telephony.RadioAccessFamily的很多问题( 错误无法找到符号类RadioAccessFamily ),该类位于android的平台框架中

Any idea for resolve this problem? 有解决这个问题的主意吗?

I found the answer myself. 我自己找到了答案。 For others interested, here here it is: 对于有兴趣的人,在这里在这里 ,它是:

create aidl folder in main folder. 在主文件夹中创建aidl文件夹。

create package com.android.internal.telephony in aidl folder 在aidl文件夹中创建包com.android.internal.telephony

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 android.permission.MODIFY_PHONE_STATE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM