In a method that registers a AlarmManager
to run every 30 seconds the BroadcastReceiver
:
public void play(View view) {
Log.i("lgg", "Botão: broadPlay");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
long intervalo = 30 * 1000;
Intent tarefaIntent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent tarefaPendingIntent = PendingIntent.getBroadcast(this, 0, tarefaIntent, 0);
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
intervalo, tarefaPendingIntent);
}
BroadcastReceiver:
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("lgg", "onReceive " + new Date());
}
But following the Log
, I see what time it runs at the correct interval, time not, time it takes 1min or even more, etc.
Would you like to know why this happens?
And what method do the large app (eg whatsapp) use for real-time scanning?