gpt4 book ai didi

android - 如何在 Android 2.3.3 中拒接/接听电话?

转载 作者:行者123 更新时间:2023-11-29 18:13:01 27 4
gpt4 key购买 nike

我正在尝试拒绝/接听 android 2.3.3 中的电话。我尝试使用 ITelephony-endcall()answerRingingCall() 但没有成功。有什么想法吗?

最佳答案

如何接听来电:

/**
* Emulates a headset button press to accept the call
*
* @param context
* A context to use
*/
public static void answerPhoneHeadsethook(Context context) {
// Simulate a press of the headset button to pick up the call
// SettingsClass.logMe(tag, "Simulating headset button");
Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");

// froyo and beyond trigger on buttonUp instead of buttonDown
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}

据我所知,在 2.3+ 中没有拒绝调用的方法(可以通过上述方法接受和拒绝调用,但调用者必须为此付费)。

关于android - 如何在 Android 2.3.3 中拒接/接听电话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9667044/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com