2012-02-06 14 views
2

私は自分の携帯電話が自動的にコールに答えることを確認しようとしていますが、Googleのように見えますが、この方法の権限を削除します。だから私はここに他の方法を見つけるAndroid:通話に自動的に応答する方法は?

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); 
Class c = Class.forName(tm.getClass().getName()); 
Method m = c.getDeclaredMethod("getITelephony"); 
m.setAccessible(true); 
ITelephony telephonyService; 
telephonyService = (ITelephony)m.invoke(tm); 
telephonyService.silenceRinger(); 
telephonyService.answerRingingCall(); 

を: http://code.google.com/p/auto-answer/source/browse/trunk/src/com/everysoft/autoanswer/AutoAnswerIntentService.java

// Simulate a press of the headset button to pick up the call 
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"); 

をしかし、それはdoesnの仕事もありません。 私は恋しいですか?

+0

あなたのマニフェストに適切な権限を追加しましたか?(http://code.google.com/p/auto-answer/source/browse/trunk/AndroidManifest.xml) – adneal

+0

はい、もちろんでした。私の電話でそれらのアプリをロードすることもできますが、それはあまりにも機能しません。 – user758030

+0

これは2.3.3で動作しますか? – user1163234

答えて

-1

変更

BUTTONUPと同じ
context.sendBroadcast(buttonDown);. 

context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED"); 

を以下に示します。 sendOrderedBroadcast()は他の受信者によって中止される可能性があるためです。

関連する問題