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