简体   繁体   中英

Communicating with Server - Android App

I have an android application which is uploading and downloading a file in every 15 min. I am using AlarmManager setRepeating() to do this, but it is consuming lot of Battery and Inefficient. But i want to restructure this app so that it will work on Marshmallow and above devices. I read about JobScheduler and sync adapter , but the challenge is Doze mode . As per Official Documentation

https://developer.android.com/training/monitoring-device-state/doze-standby.html#understand_app_standby

JobScheduler and Sync Adapter wont work on Doze mode.

So, How to make android app and server communication for every 15 min, even in doze mode.

Thanks.

As per Android developer documents AlarmManager will continue work on marshmallow and above

Standard AlarmManager alarms (including setExact() and setWindow()) are deferred to the next maintenance window.

  1. If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle() .
  2. Alarms set with setAlarmClock() continue to fire normally — the system exits Doze shortly before those alarms fire.

Use Alarmmanager and let your users deactivate Doze mode for your app (Whitelisting).

Alarmmanager do not consuming a lot of Battery. Alarm event comes from operating system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM