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.