ヘッドセットのボタン入力を取得する方法について教えて下さい
ネットによくあるサンプル(AndroidManifest.xmlに必要な記述を行うもの)と以下の1つを試したのですがうんともすんとも取得できません。
****
ScreenReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
if (action.equals(Intent.ACTION_SCREEN_ON)) {
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
} else if (action.equals(Intent.ACTION_MEDIA_BUTTON)){
}
}
}
};
this.registerReceiver(ScreenReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
this.registerReceiver(ScreenReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
this.registerReceiver(ScreenReceiver, new IntentFilter(Intent.ACTION_MEDIA_BUTTON));
****
オーバーライドしたKeyDownではボタン入力を取得できるのですが、Broadcastに関してはネットのサンプルの方は全く反応せず、
上記のものはスクリーンのオンオフしか取得できません。
必要なPermission指定等があるのでしょうか?