2

Recently i received an performance report from google play store(Android Vitals) and the report is given below

Excessive Alarm Manager wakeups Percentage of battery sessions during which users experienced more than 10 wakeups per hour. A battery session is the period between two full charges of a device. Data is collected only when the device is off charger.

https://developer.android.com/topic/performance/vitals/wakeup.html

i tried the above idea, but i did't get any clear idea how to fix Excessive Wakeups

My Code is given below

public void registerAlarm() 
{
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Calendar alarmTime = Calendar.getInstance();
    PendingIntent poperation = PendingIntent.getService(this, 0, getIntentForNotification(this), 0);
    alarmManager.cancel(poperation);
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion < android.os.Build.VERSION_CODES.KITKAT) {
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(), 1 * 60 * 60 * 1000, poperation);
    } else {
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(), 1 * 60 * 60 * 1000, poperation);
    }
}

Note: am using WAKE_LOCK permission in my application

Sarath Kumar
  • 1,922
  • 3
  • 19
  • 43

0 Answers0