2012-03-12 8 views
1

私は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以降でコールを拒否する方法はありません(上記の方法で呼び出しを受け入れ、拒否することが可能であろう:着信に応答する方法

答えて

2

しかし、その後、呼び出し側が支払う必要があります)。

+0

ルーキー質問に申し訳ありませんが、私の活動からこのメソッドを呼び出しています。コンテキスト(getapplicationcontext?)の代わりに私は何を使うべきですか? – user1163234

+0

'YOURACTIVITY.this' - 、それは私の、デバイスにHTC信じられないほどのSの上に私のエミュレータの上で作業していないが、getApplicationContext' – Force

+0

' 'よりthis'を使用することが常に良いです....任意のアイデア? – user1163234

1

この目的を前に送信する必要があります。

Intent headSetUnPluggedintent = new Intent(Intent.ACTION_HEADSET_PLUG); 
       headSetUnPluggedintent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 
       headSetUnPluggedintent.putExtra("state", 1); 
       headSetUnPluggedintent.putExtra("name", "Headset"); 

       // TODO: Should we require a permission? 
      sendOrderedBroadcast(headSetUnPluggedintent, null); 
関連する問題