3

I am developing an app to check Wi-Fi status. If there aren't Wi-Fi connection, the app has to show the disconnect symbol. From Marshmallow onwards, if the device enters in "Doze mode", my device network enters into suspended mode.

If I wake my device up by pressing the power button, will Wi-Fi automatically become Active state?

Oriol Roma
  • 329
  • 1
  • 5
  • 9
kavie
  • 2,154
  • 4
  • 28
  • 53

1 Answers1

3

Network will be always active, its just the access to it by apps gets suspended. System decides when to allow it.

Based on the documentation:

As soon as the user wakes the device by moving it, turning on the screen, or connecting a charger, the system exits Doze and all apps return to normal activity

So if you turn on the screen, then the access to network will be granted, provided you app is not in standby mode.

Sagar
  • 23,903
  • 4
  • 62
  • 62
  • ok.Consider device is it Idle/Doze mode,during that time i'm getting one notification from Third party Server.Since network is in suspended state,I will miss that notification right?.How can I make my app always connected to network even in doze mode also? – kavie Jun 05 '18 at 07:10
  • @kavie You can use FCM high-priority messages which lets you reliably wake your app to access the network, even if the user’s device is in Doze or the app is in App Standby mode. – Sagar Jun 05 '18 at 07:12
  • I can't go with FCM in my projects.Is there any way available to make android wear app always connected to Internet? – kavie Jun 05 '18 at 07:33
  • @kavie I am not so familiar with wear app. You can create a new question and check if someone else could help. – Sagar Jun 05 '18 at 07:35
  • @Sagar.This doze behavior is same in android phone also right? – kavie Jun 05 '18 at 07:36
  • @kavie Yes. Should be. On phones you can schedule Job using JobScheduler or AlarmManager to periodically check the data availability. Do remember, minimum period for JobScheduler is around 15 minutes – Sagar Jun 05 '18 at 07:41
  • @kavie There is some maintenance window during doze mode. Scheduled jobs will be executed during this time. Availability of maintenance window is OS implementation dependant. – Sagar Jun 05 '18 at 09:13
  • Consider Android device is in Doze mode when it receives notification from Server.App will not receives notification.When it enters in to Manitance window that time only it will receive or If user touch on screen that time it will receive.IS THERE ANY WAY TO MAKE DEVICE AWAKE ONCE IT RECEIVES NOTIFICATION FROM THIRD PARTY SERVER? – kavie Jun 05 '18 at 09:20
  • @kavie `IS THERE ANY WAY TO MAKE DEVICE AWAKE ONCE IT RECEIVES NOTIFICATION FROM THIRD PARTY SERVER? ` No – Sagar Jun 05 '18 at 09:52
  • I use AlarmManager, but after approximately 2 hours (every minute showing notification) don't execute anymore. Why is this happen? `alarmMgr = (AlarmManager)this.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, NotificationBroadcastReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 1, intent, 0); alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INTERVAL_ONE_MINUTE, INTERVAL_ONE_MINUTE, alarmIntent); – Valentin Gjorgoski Aug 26 '19 at 11:10