我有两项活动,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