Android 安卓工作室接听来电
我知道很多开发人员都会问同样的问题,如何在点击按钮时接受来电 我正在做这样的应用程序。 我搜索了很多,并成功地实现了应用程序可以检测来电的功能(通过跟踪此功能),并打开了一个用户有两个选择的活动,即接受来电还是拒绝来电。问题在于我无法以编程方式接受/拒绝传入呼叫。我搜索了很多,但没有找到具体的解决方案。如果有人能帮助我如何以编程方式接受来电,那将非常好。也许你可以试试 通过{@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)} 获取TelecomManager对象,然后调用acceptRingingCall()方法进行应答,或者调用endCall()方法拒绝调用Android 安卓工作室接听来电,android,telephony,telephonymanager,Android,Telephony,Telephonymanager,我知道很多开发人员都会问同样的问题,如何在点击按钮时接受来电 我正在做这样的应用程序。 我搜索了很多,并成功地实现了应用程序可以检测来电的功能(通过跟踪此功能),并打开了一个用户有两个选择的活动,即接受来电还是拒绝来电。问题在于我无法以编程方式接受/拒绝传入呼叫。我搜索了很多,但没有找到具体的解决方案。如果有人能帮助我如何以编程方式接受来电,那将非常好。也许你可以试试 通过{@link Context#getSystemService Context.getSystemService(Cont
public class TelecomManager {
/**
* If there is a ringing incoming call, this method accepts the call on behalf of the user.
*
* If the incoming call is a video call, the call will be answered with the same video state as
* the incoming call requests. This means, for example, that an incoming call requesting
* {@link VideoProfile#STATE_BIDIRECTIONAL} will be answered, accepting that state.
*
* Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or
* {@link android.Manifest.permission#ANSWER_PHONE_CALLS}
*/
//TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use
// this method (clockwork & gearhead).
@RequiresPermission(anyOf =
{Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE})
public void acceptRingingCall() {
try {
if (isServiceConnected()) {
getTelecomService().acceptRingingCall(mContext.getPackageName());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e);
}
}
从Marshmallow发布以来,访问用户的电话和数据需要运行时权限 现在,来回答您的问题,从语法上讲,要通过接听电话,您需要2个权限
Manifest.permission.接听电话
和Manifest.permission.修改电话状态
但MODIFY_PHONE_状态为不供第三方应用程序使用
读这个