Android setInexactRepeating杀死电池

时间:2014-06-06 14:34:55

标签: android broadcastreceiver alarm battery

我的一些应用程序用户抱怨我的应用程序正在扼杀他们的电池,但我很难搞清楚问题。谁能发现我可能出错的地方?

https://play.google.com/store/apps/details?id=com.walkingroutes.beta01

public class BootReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent callingIntent) {
           long interval = 86400000;//set interval 86400000 = 24 hours
           AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 
           int alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP;
           long timeOrLengthofWait = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
           Intent intent = new Intent(context, UpdaterService.class); 
           PendingIntent pendingIntent = PendingIntent.getService(context, -1, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
           alarmManager.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis(), interval, pendingIntent);
      } 
}

0 个答案:

没有答案