Pass values ​​in crash manager

how to pass the value to the receiver ... I use the alarm manager ...

+5
source share
1 answer

Use PendingIntentthat Intenthas optional extras.

This has been changed with the AlarmController Google APIDemo :

Intent intent = new Intent(AlarmController.this, RepeatingAlarm.class);
intent.putExtra("some_name", some_value);
PendingIntent sender = PendingIntent.getBroadcast(AlarmController.this,0, intent, 0);

// We want the alarm to go off 30 seconds from now.
long firstTime = SystemClock.elapsedRealtime();
firstTime += 15*1000;

// Schedule the alarm!
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, 15*1000, sender);

Then extract those from your recipient onReceive():

intent.getStringExtra("some_name")
+6
source

All Articles