我有兩項活動,A和B.活動A用廣播接收器捕獲意圖,活動B觸發它。活性A的未收到定製意圖
代碼:
在活動AI也註冊用下面的代碼的接收器:
活性B的IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
filter.addAction(floatyNetworkList.CONNECT_INTENT);
registerReceiver(mReceiver, filter);
代碼,我的意圖進行燒成時,我選擇的項目我的列表視圖:
listBtview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterBt, View myView, int myItemInt, long mylng) {
@SuppressWarnings("unchecked")
HashMap<String,String> selectedFromList =(HashMap<String,String>) (listBtview.getItemAtPosition(myItemInt));
Toast.makeText(getBaseContext(), selectedFromList.get("Name"), Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), Floaty.class);
intent.setAction(CONNECT_INTENT);
intent.putExtra("Device",fetchDevice(selectedFromList.get("Address")));
getApplicationContext().sendBroadcast(intent);
}
});
}
問題是活動A永遠不會收到意圖。我還爲我的自定義意圖添加了過濾器,並正確更新了我的清單。
清單代碼:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="com.vittorio.intent.action.CONNECT_INTENT"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
任何想法?
謝謝
你註冊你的接收器嗎? – pskink 2013-05-07 14:38:29
您可以向我們展示BroadcastReceiver註冊的代碼或聲明的代碼 – k3b 2013-05-07 14:38:31
您可以發佈您的清單嗎? – 2013-05-07 14:38:38