为什么这项工作:子类意向不发送额外
sendBroadcast(MyUtil.configMyIntent(
new Intent(),
ActionType.DATE,
new Date().toString()));
有:
public static Intent configMyIntent(Intent intent, ActionType actionType, String content){
intent.setAction("myCustomBroadcastIntentAction");
intent.putExtra("actionType",actiontype);
intent.putExtra("content", content);
return intent;
}
但是使用子类时:
CustomIntent intent = new CustomIntent(ActionType.DATE, new Date().toString());
sendBroadcast(intent);
与
public class CustomIntent extends Intent {
public CustomIntent(ActionType actionType, String content) {
super();
this.setAction("myCustomBroadcastIntentAction");
this.putExtra("actionType",actionType);
this.putExtra("content", content);
}
}
附加信息不会添加到意图中,并且在BroadcastReceiver中接收时为空?
你能解释一下为什么吗? –