Android拒绝来电 [英] Android reject incoming call

查看:128
本文介绍了Android拒绝来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的android项目中(目标sdk版本为23),我想拒绝来电。
我知道对此有很多疑问,特别是

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 如何将com.android.internal.telephony.ITelephony导入Android应用程序

2 如何拒绝在android中以编程方式调用

3 当我检测到来电时如何拒绝任何来电

在第一个链接中,建议解决方案是在接口 ITelephony 上使用反射,因为它是一个内部接口。但是此解决方案使用 MODIFY_PHONE_STATE 权限,该权限只能授予系统应用程序,因此无论如何它都无法正常工作。

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.

从第二和第三个链接,我了解解决方案是从 ITelephony /ext/com.google.android/android/5.1.0_r1/com/android/internal/telephony/ITelephony.java#ITelephony.getRadioAccessFamily%28int%29\"rel =nofollow noreferrer>这里然后把它放进去在我的解决方案中的 com.android.internal.telephony 的新包中。
问题是在这个界面中有很多关于查找类 android.telephony.RadioAccessFamily 的问题(错误找不到符号类 RadioAccessFamily ),该类位于 android的平台框架基础

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?

推荐答案

我自己找到了答案。对于其他感兴趣的人,这里是:

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

创建援助主文件夹中的文件夹。

create aidl folder in main folder.

在aidl文件夹中创建包com.android.internal.telephony

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

创建一个援助文件包:

interface ITelephony {      

    boolean endCall(); 
    void answerRingingCall();      

}

关于结束通话的代码请参阅<中的答案a href =https://stackoverflow.com/a/18065415/1970301>链接。

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

并且没有必要添加权限


android.permission.MODIFY_PHONE_STATE

android.permission.MODIFY_PHONE_STATE

这篇关于Android拒绝来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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