我试图在 ListActivity 调用的 BroadcastReceiver 中接收一些数据。它被调用,我已经测试过了,但是 getExtras 总是返回 NULL。
这是我的 ListActivity 中有趣的部分:
public boolean onContextItemSelected(MenuItem item) {
Intent distIntent = new Intent();
distIntent.setAction(Intent.ACTION_SEND);
distIntent.putExtra("fileName", new File("Test").getName());
sendBroadcast(distIntent);
}
这是我的 BroadcastReceiver 的相应部分:
public void onReceive(Context c, Intent intent){
String b = intent.getStringExtra("fileName");
if(b != null)
Log.e(logTag, "File Name: "+b);
}
该文件存在,其名称已正确添加到意图中,但由于某种原因它没有传播到我的接收器。
任何建议表示赞赏!