1
你能幫我找出爲什麼brodcast reciver的註冊返回null嗎? 這是代碼:註冊reciver過濾器,無法找到
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);
}
,這是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);
}
我已閱讀本Java文檔,但在粥手這個[鏈接] |(HTTP:// developer.android.com/reference/android/bluetooth/BluetoothHeadset.html)是關於brodcast意圖不粘性,在ather函數中提到dirctly – 2012-03-27 16:41:49
http://developer.android.com/reference/android/bluetooth/BluetoothHeadset.html in這:ACTION_CONNECTION_STATE_CHANGED – 2012-03-27 16:45:00
我完全糊塗 – 2012-03-27 17:10:15