3

在我的代码中,我正在使用 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);

有什么理由我应该选择一种技术而不是另一种?

4

1 回答 1

3

使用任何你想要的适合你的技术。有时您需要一个独特的PendingIntent但您不能使用独特的操作,因为该操作用于其他目的(意图解析或其他)。

于 2013-06-05T15:31:38.267 回答