Vishnu
Vishnu

Reputation: 349

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

Upvotes: 6

Views: 8272

Answers (1)

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");  

Upvotes: 10

Related Questions