2011-09-09 8 views
0

Android 오디오 응용 프로그램을 개발 중입니다. 이제는 을 캡처하고 오디오를 재생하고 새로운 기능인 bluetooh 헤드셋을 통해 캡처 및 재생 기능을 추가하고 싶습니다.Intent.ACTION_MEDIA_BUTTON 이벤트 캡처

그것에 대해 읽기, 나는 ACTION_MEDIA_BUTTON 이벤트를 관리해야합니다 보인다되었습니다

자바 파일 :

.... 

public class audioBroadcastReceiver extends BroadcastReceiver 
{ 
    public void onReceive(Context context, Intent intent) 
    { 
     if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) 
     { 
      Log.d("","@@@@ WORKS"); 
     } 
     else 
    { 
    Log.d("","@@@@ ????");      
} 
.... 

XML 파일

.... 
<receiver android:name="audioBroadcastReceiver"> 
    <intent-filter>  
     <action android:name="android.intent.action.MEDIA_BUTTON"> 
     </action> 
    </intent-filter> 
</receiver> 
<uses-permission android:name="android.permission.BLUETOOTH" /> 

그러나 아무 일도 일어나지 않아, 누군가 나에게 모범을 보이거나 ide를 줄 수있다. a 대상 :

1º 블루투스가 연결되었을 때를 알 수 있습니다.

2º 오디오 패킷을 블루투스 헤드셋을 통해 라우팅합니다.

감사합니다.

답변

0

bluetoothAdapter 메서드가 필요합니다. BluetoothAdapter blueT = BluetoothAdapter.getDefaulAdapter();

// create broadcast receiver 
BroadcastReceiver blueReceiver = new BroadcastReceiver(){ 
// todo switch states to turn on or off or check is on 
// check is on is something like this: 
case (blueT.STATE_ON) : { 
// do something with it 
} 

if(blueT.isEnabled()){ 
do something 
} 
+0

감사합니다.하지만 작동하지 않습니다. 또한 ACTION_MEDIA_BUTTON을 캡처해야합니다. – Chris

관련 문제