I have simply functional for start service and repeat he:
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
PendingIntent pIntent = PendingIntent.getService(mContext,
SendStatusService.SEND_STATUS_SERVICE_CODE,
mIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + 2000,
mIntervalInMs,
pIntent);
I understand the documentation: alarm manager regardless of device state (sleep or not) start service through 2000 ms and repeat with interval mIntervalInMs
.
But service start working after 30-50 sec after running this code. What i make wrong or no understand the documentation?