I want an Alarmmanager to fire first time after 2 Seconds and then every 10 Sec.
It doesn't fire the first time exactly 2 seconds later. Something between 5 and 10 sec later. And it doesn't repeat at all.
Here is my Code:
Alarmmanager:
Intent intent = new Intent(this, BackgroundService.class);
final PendingIntent pendingintent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
final AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis() + 2 * 1000, 10 * 1000, pendingintent);
Manifest:
<receiver android:process=":remote" android:name=".BackgroundService"/>
BackgroundService.java:
public class BackgroundService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("BackgroundService", "BackgroundService onReceive");
}
}
Got it:
The IDE says: The 3rd value will be forced up to 60000 (1 Min) to save battery. But I never waited so long, so it looked like it doesn't even repeates.