Is it possible to get requestCode at the time of intent either in Receiver class or Activity Class?
and this was my pending Intent
alarmMgr= (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, BroadcastReceiver_Class.class);
/*intent.putExtra("alarm_time_minutes", minutes);*/
pendingIntent = PendingIntent.getBroadcast(this, requestCode, intent,requestCode);
alarmMgr.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
Thanks in Advance..
In other words, PendingIntent lets us pass a future Intent to another application and allow that application to execute that Intent as if it had the same permissions as our application, whether or not our application is still around when the Intent is eventually invoked.
1- requestCode is used to get the same pending intent later on (for cancelling etc) 2- Yes, they will get override as long as your specify the same Receiver to your Intent that you specify on your PendingIntent.
So there is no actual difference between the two.
The application specifies a PendingIntent callback (typically an IntentService) which will be called with an intent when activities are detected. The intent recipient can extract the ActivityRecognitionResult using ActivityRecognitionResult.
You can put requestCode
as extra to your intent. Like following:
intent.putExtra("requestCode", requestCode);
Then you can get it in Activity class by:
int requestCode = received_intent.getExtras().getInt("requestCode");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With