在机器人编程结束通话 [英] End call in android programmatically
问题描述
我看到了很多问题,这是不可能结束调用编程的机器人。 与此同时,我看到很多拨号器应用程序在googleplay市场,可以激活呼叫,并把它也。它们是如何工作的?
I see a lot of questions that it's impossible to end call programmatically in Android. At the same time, I see a lot of dialer apps in googleplay market where you can activate the call and drop it also. How do they work?
修改:我曾经读过我的应用程序必须是系统的应用程序。那么如何使它的系统,什么是系统和用户应用程序之间的区别是什么?
Edit: I've read somewhere that my app has to be system app. Then how to make it system, and what is the difference between system and user apps?
推荐答案
您不必为系统的应用程序。首先,在你的项目中创建包com.internal.android.telephony,并把它放进一个名为ITelephony.aidl的文件:
You do not need to be a system app. First, create package com.internal.android.telephony in your project, and put this in a file called "ITelephony.aidl":
package com.android.internal.telephony;
interface ITelephony {
boolean endCall();
void answerRingingCall();
void silenceRinger();
}
一旦你有,你可以使用这个code结束通话:
Once you have that, you can use this code to end a call:
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(telephonyManager.getClass().getName());
Method method = clazz.getDeclaredMethod("getITelephony");
method.setAccessible(true);
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
telephonyService.endCall();
您可以一PhoneStateListener内使用,例如。对于这个工作,你需要在明显的权限:
You could use this inside a PhoneStateListener, for example. For this to work, you require permissions in manifest:
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
编辑:道歉可怕的格式,我仍然无法弄清楚如何正确地在这里做code块:/
Apologies for horrible formatting, I still can't figure out how to properly do code blocks here :/
这篇关于在机器人编程结束通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!