android.permission.ANSWER_PHONE_CALLS如何使用?自动应答 [英] android.permission.ANSWER_PHONE_CALLS How I can use? for auto answer

查看:1700
本文介绍了android.permission.ANSWER_PHONE_CALLS如何使用?自动应答的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Android开发人员文档

Android 8.0(API级别26)引入了一些与新权限相关的 通话:ANSWER_PHONE_CALLS权限允许您的应用执行以下操作: 以编程方式接听来电.处理传入 在您的应用中拨打电话,您可以使用acceptRingingCall()方法.

Android 8.0 (API level 26) introduces several new permissions related to telephony: The ANSWER_PHONE_CALLS permission allows your app to answer incoming phone calls programmatically. To handle an incoming phone call in your app, you can use the acceptRingingCall() method.

我的应用程序如何为来电提供语音应答?

How my app give voice answer to incoming call ?

但是我还没有找到有关此的任何指南或示例. 所以

but I have not found any guide or examples about of this . so

我想要语音自动应答(来自应用程序的原始文件夹) (我需要诸如答录机之类的指南或示例代码)

I want automatic answer with voice(from raw folder in app) (I have need guide or example code like answering machine)

推荐答案

接受应答呼叫已弃用API LEVEL Q

try {
                    Toast.makeText(CallAnswerDialog.this, "btn_answer click", Toast.LENGTH_SHORT).show();

                    TelecomManager tm = (TelecomManager) CallAnswerDialog.this.getSystemService(Context.TELECOM_SERVICE);
                    if (tm == null) {
                        // whether you want to handle this is up to you really
                        throw new NullPointerException("tm == null");
                    }
                    tm.acceptRingingCall();   // is deprecated Now API Level Q
                    btn_answer.setVisibility(View.GONE);
                }catch (Exception e){
                    e.printStackTrace(); }

这篇关于android.permission.ANSWER_PHONE_CALLS如何使用?自动应答的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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