Retrieving the request code from the broadcastReceiver alarm clock

I send a request code through this to the alarm manager

 Intent broadcast_intent = new Intent(this, AlarmBroadcastReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, rowId,  broadcast_intent, PendingIntent.FLAG_UPDATE_CURRENT);

I was wondering that in the translator, how can I recover the request code (rowId) that I used to configure pendingIntent?

thank

+5
source share
3 answers

I was looking for the same thing. One way is to pass the request code as optional in its intention.

intent.putExtra("requestcode", rowId);

However , if the application is killed, there is no way to get the data transmitted using the intent.

So you need to pass rowId as URI and use Intent Filter.

+2
source
Intent broadcast_intent = new Intent(this, AlarmBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, rowId,
                              broadcast_intent,PendingIntent.FLAG_UPDATE_CURRENT
                              );

broadcast_intent getBroadcast() - broadcast_intent.putExtras("REQUESTCODE",rowId) ; :

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, rowId,
                              broadcast_intent.putExtras("REQUESTCODE",rowId), 
                              PendingIntent.FLAG_UPDATE_CURRENT);
+2

RequestCode, pendingIntent, , , pendingIntent, pendingIntents.

, - pendingIntents, . , /.

, putExtra, . , RowId requestCode Extra.

+2

All Articles