2

私は自分の電話が自動的に電話に応答するようにしようとしていますが、Google はこの方法でアクセス許可を削除するように見えます:

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");

しかし、それもうまくいきません。何が恋しい?

4

1 に答える 1

-1

以下を変更

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

context.sendBroadcast(buttonDown);.

buttonUp と同じです。sendOrderedBroadcast()他の受信者によって中止される可能性があるためです。

于 2014-10-13T07:25:38.883 に答える