私はAndroid 2.3.3でコールを拒否/応答しようとしています。私はITelephony-endcall()
とanswerRingingCall()
を使ってみましたが、成功しませんでした。何か案は?Android 2.3.3でコールを拒否/応答するにはどうすればよいですか?
/**
* 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以降でコールを拒否する方法はありません(上記の方法で呼び出しを受け入れ、拒否することが可能であろう:着信に応答する方法
ルーキー質問に申し訳ありませんが、私の活動からこのメソッドを呼び出しています。コンテキスト(getapplicationcontext?)の代わりに私は何を使うべきですか? – user1163234
'YOURACTIVITY.this' - 、それは私の、デバイスにHTC信じられないほどのSの上に私のエミュレータの上で作業していないが、getApplicationContext' – Force
' 'よりthis'を使用することが常に良いです....任意のアイデア? – user1163234