0
我想設置一個重複的警報,它會在Bundle的第一個觸發器上發送字符串「test」。您可以爲AlarmManager setInexactRepeating使用不同的捆綁包嗎?
是否有可能在下一個觸發器有另一個字符串像「test2」?
報警經理:
// Enable the scheduled alarm to send notifications
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent alarmIntent = new Intent(this, Service.class);
Bundle extras = new Bundle();
extras.putString("test", "test");
alarmIntent.putExtras(extras);
PendingIntent alarmPendingIntent = PendingIntent.getService(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// Set the alarm in 30 minutes and repeat it every 30 minutes.
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + 1000,
1000,
alarmPendingIntent);
IntentService:
public class Service extends IntentService {
public Service() {
super("service");
}
@Override
protected void onHandleIntent(Intent intent) {
String test = intent.getStringExtra("test");
// update the bundle data
Log.i("result", test);
// how to update here the string to "test2" ?
}
}
我想在第二個觸發的String test
值是test2
。
但我總是從第一個觸發器獲得原始值。