With the introduction of Doze in Android M and Android getting more and more restrictive with background executions during Doze. Could someone elaborate if the same thing applies when extending Android's own services. For example NotificationListenerService?
I am using it as such
public class ListenForNotificationsService extends
NotificationListenerService {
private String TAG = this.getClass().getSimpleName();
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.d(TAG, "Notification received");
// Do AsyncTask() for network request
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
if (sbn.getPackageName() != null) {
Log.d(TAG, "Notification removed:" + sbn.getPackageName() + ":" + sbn.getId());
}
}
}
It stops working after a couple of minutes when the device goes into Doze. I have tried using AlarmManager, JobScheduler, JobIntentService and normal IntentService. None of them work when the device deep sleeps.
As a side note, my device is a Huawei Mate 10 Pro. And they have been known for aggressive task management. But I have Whitelisted my app, disabled everything that can be disabled from Huawei's side that kills off apps in the background.
Any advice on how I can call an AsyncTask while the device is Dozing (relative to Google's rules about maintenance windows, I am aware that under Doze Google defers network requests, wake locks and so on. I just want the network request to be executed when Google allows).