title: Alarm manager for background services
body: <p>I have implemented the alarm manager to wake up the background services every 15 mins periodically. It is working fine, but since the inclusion of DOZE mode Android 6.0, the seems like behaving strange and not waking up in every 15 mins. Although, I am using the method alarm.setExactAndAllowWhileIdle(), but still not working in Idle state</p>
  
  <p>here is my method for implementing Alarm Manager</p>
  
  <pre><code> private void serviceRunningBackground()
  {
      final Intent restartIntent = new Intent(this, service.class);
      restartIntent.putExtra("ALARM_RESTART_SERVICE_DIED", true);
      alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
     Handler restartServiceHandler;
      restartServiceHandler = new Handler() {
           @Override
           public void handleMessage(Message msg) {
               pintent = PendingIntent.getService(getApplicationContext(), 0, restartIntent, 0);
               if (Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.LOLLIPOP_MR1) {
                   Log.d(TAG, " Marshmellow "+ TIMER_START_TIME);
                   alarmMgr.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, 900000, pintent);                  
               } else {
                   alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 900000, pintent);
               }
               sendEmptyMessageDelayed(0, TIMER_START_TIME);
           }
       };
      restartServiceHandler.sendEmptyMessageDelayed(0, 0);
  }
  </code></pre>
  
  <p>Any help would be appreciated..thanks</p>