using IntentExatras with Alarm Manager

Posted by Ashwin on Stack Overflow See other posts from Stack Overflow or by Ashwin
Published on 2012-09-04T03:29:31Z Indexed on 2012/09/04 3:38 UTC
Read the original article Hit count: 133

Filed under:
|

I want to know if this code will work(I cannot try it out right now. Moreover, I have a few doubts that have to be cleared).

 Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra("user",global.getUsername());
intent.puExtra("password",global.getPassword);
PendingIntent sender = PendingIntent.getBroadcast(context, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the AlarmManager service


           Log.v("inside log_run", "new service started");
           AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
           am.setRepeating(AlarmManager.RTC_WAKEUP, IMMEDIATELY,60000,sender);
           finish();


As you can see, this code starts an AlarmManager with setRepeating(). If you see the intent(actually the pending intent) passed on to the BroadcastReceiver, there are two extras that are passed on. These are global variables that live as long as the Application is running. But this AlarmManager is meant to be run in the background (that is application will be alive only for the first few calls of the o fthe alrmamanager to the broadcast recevier)
My Question
Will AlarmManager make a copy of the global variables(the username and password) and maintain this copy to be passed along with the intent? Because, these values will be used in the broadcast receiver.

© Stack Overflow or respective owner

Related posts about android

Related posts about alarmmanager