Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get requestCode from pending intent at the time of alarm in android

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..

like image 782
Vishnu Avatar asked Nov 27 '12 14:11

Vishnu


People also ask

What is pending intent in notification?

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.

What is pending intent request code?

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.

What is the difference between intent and PendingIntent?

So there is no actual difference between the two.

What is PendingIntent callback?

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.


1 Answers

You can put requestCodeas 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");  
like image 53
Kerim Oguzcan Yenidunya Avatar answered Sep 21 '22 16:09

Kerim Oguzcan Yenidunya