Android:android2.3电话接听

 

  
  
  
  
  1. /** 
  2.  * 该方式只适用2.3及2.3以上版本 
  3.  */ 
  4. private synchronized void answerRingingCall(){ 
  5.     try { 
  6.         Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG); 
  7.         localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
  8.         localIntent1.putExtra("state"1); 
  9.         localIntent1.putExtra("microphone"1); 
  10.         localIntent1.putExtra("name""Headset"); 
  11.         sendOrderedBroadcast(localIntent1, "android.permission.CALL_PRIVILEGED"); 
  12.          
  13.         Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON); 
  14.         KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK); 
  15.         localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1); 
  16.         sendOrderedBroadcast(localIntent2, "android.permission.CALL_PRIVILEGED"); 
  17.          
  18.         Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON); 
  19.         KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK); 
  20.         localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2); 
  21.         sendOrderedBroadcast(localIntent3, "android.permission.CALL_PRIVILEGED"); 
  22.          
  23.          
  24.         Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG); 
  25.         localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
  26.         localIntent4.putExtra("state"0); 
  27.         localIntent4.putExtra("microphone"1); 
  28.         localIntent4.putExtra("name""Headset"); 
  29.         sendOrderedBroadcast(localIntent4, "android.permission.CALL_PRIVILEGED"); 
  30.     } catch (Exception e) { 
  31.         Log.i("answerRingingCall:",e.getMessage()); 
  32.     } 

 

你可能感兴趣的:(android,移动开发,职场,电话,休闲)