爲什麼這項工作:子類意向不發送額外
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中接收時爲空?
你能解釋一下爲什麼嗎? –