PendingIntent的getBroadcast和getService

时间:2015-05-25 14:31:24

标签: java android android-intent android-pendingintent

请求getCroadcast和getService的requestCode代码是否相同? 例如,

Intent intent = new Intent(INTENT_FILTER);
PendingIntent sender = PendingIntent.getBroadcast(ctx, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.cancel(sender);
sender.cancel();

Intent intentS = new Intent(ctx, MyService.class);
PendingIntent senderS = PendingIntent.getService(ctx, requestCode, intentS, PendingIntent.FLAG_CANCEL_CURRENT);

am.cancel(senderS);
senderS.cancel();

1 个答案:

答案 0 :(得分:1)

是。因为还有其他因素可用于区分sender。在您的情况下,senderS有一个ACTION,而{{1}}没有ACTION,但有一个组件(包和类)。