1

Can u help me find out why the registration of broadcast receiver returns null? this is the code:

ScoIntent = new IntentFilter(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
                sReceiver = new ScoReceiver(context, Tmp); 
                if (context.registerReceiver(sReceiver, ScoIntent) == null) {
                    Log("FBR.GetBlueConnect:Error", "Can not find receiver ACTION_CONNECTION_STATE_CHANGED");
                    HFS.DisplayText("Can not connect to Bluetooth Headset, Please Exit", true);
                }

and this is the reciver:

class ScoReceiver extends BroadcastReceiver {      
    public ScoReceiver(Context mcontext, Tools t){
    bContext = mcontext;
    tools = t;
}
@Override 
public void onReceive(Context context, Intent arg1) { 
    tools.Log("ScoReceiver:onReceive", "In");

    //arg1 = new Intent(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED); 
    String action = arg1.getAction();
    tools.Log("ScoReceiver:onReceive", ">>> Bluetooth SCO state changed !!! ");
    if(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
        int status = arg1.getIntExtra(BluetoothHeadset.EXTRA_STATE, AudioManager.SCO_AUDIO_STATE_ERROR );

}

Cœur
  • 37,241
  • 25
  • 195
  • 267
c v
  • 74
  • 3
  • 7

1 Answers1

0

The javadocs say,

Returns the first sticky intent found that matches filter, or null if there are none.

Does this receiver have a sticky intent? Here's a post that talks about the difference between a stick and non-sticky intent,

what is the difference between sendStickyBroadcast and sendBroadcast in Android

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • I have read this java doc but on the ather hand this [link]|(http://developer.android.com/reference/android/bluetooth/BluetoothHeadset.html) is about brodcast intents not sticky which wre mentioned dierctly in ather functions – c v Mar 27 '12 at 16:41
  • http://developer.android.com/reference/android/bluetooth/BluetoothHeadset.html in this :ACTION_CONNECTION_STATE_CHANGED – c v Mar 27 '12 at 16:45
  • please read about sticky intents: http://stackoverflow.com/questions/3490913/what-is-a-sticky-intent-android – Jeffrey Blattman Mar 27 '12 at 20:53