在我的代码中,我正在使用 getBroadcast() 创建各种 PendingIntent 对象。
我的应用程序需要表示几种不同类型的 PendingIntent,因此我使用不同的操作字符串(每个 PendingIntent 唯一)创建底层 Intent。
我的问题是 - 通过请求代码区分待处理的意图或坚持我现在正在做的技术有什么区别吗?
例子:
我现在在做什么:
Intent intent = new Intent(Receiver.class);
intent.setAction("unique.name.here");
PendingIntent.getBroadcast(this, 0, intent, flags);
其他技术:
Intent intent = new Intent(Receiver.class);
PendingIntnt.getBroadcast(this, uniqueId, intent, flags);
有什么理由我应该选择一种技术而不是另一种?