2013-05-28 41 views

回答

-1

接受你這樣的按鈕事件創建一個廣播接收器,

public class YourBoardcastReceiver extends BroadcastReceiver { 
    public void onReceive(Context context, Intent intent) { 
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { 
     /* handle media button intent here by reading contents */ 
     /* of EXTRA_KEY_EVENT to know which key was pressed */ 
    } 
} 

}

和艙單,

<receiver android:name="YourBoardcastReceiver"> 
      <intent-filter> 
        <action android:name="android.intent.action.SCREEN_ON" /> 
      </intent-filter> 

相關問題