Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
- KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_HEADSETHOOK);
- i.putExtra(Intent.EXTRA_KEY_EVENT, event );
- context.sendOrderedBroadcast(i, null);
- try {
- Thread.sleep(800);
- Process process = Runtime.getRuntime().exec(new String[]{ "su","-c","input keyevent 5"});
- process.waitFor();
- }catch (Exception e) {
- e.printStackTrace();
- }
- try {
- Thread.sleep(800);
- Process process = Runtime.getRuntime().exec(new String[]{ "su","-c","input keyevent 6"});
- process.waitFor();
- }catch (Exception e) {
- e.printStackTrace();
- }
- Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
- buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
- KeyEvent.KEYCODE_CALL));
- 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_CALL));
- context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
- Log.d(tag, "InSecond Method Ans Call");
- // 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));
- sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
- Intent headSetUnPluggedintent = new Intent(Intent.ACTION_HEADSET_PLUG);
- headSetUnPluggedintent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- headSetUnPluggedintent.putExtra("state", 0);
- headSetUnPluggedintent.putExtra("name", "Headset");
- try {
- sendOrderedBroadcast(headSetUnPluggedintent, null);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- adb shell am start -n com.android.phone/.InCallScreen -a android.intent.action.ANSWER
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement