3

I'm using Android Studio and i'm trying to test my app when using Doze mode. I've read some links already(including the android documentation about doze mode). However, i'm getting confused. Is there any difference between "IDLE" and "Doze mode"? It seems to me they are treated as the same thing whenever I read about them.

Moreover, I was expecting that after awakening from Doze Mode, the onCreateView() method would be called again in the activity. Is that correct? I've tried to force the Doze mode with ADB and awakening it later, launching the app, going to the activity I want to test, and then using:

adb shell dumpsys battery unplug

adb shell dumpsys deviceidle force-idle

adb shell input keyevent KEYCODE_WAKEUP

However, the onResume() method was called instead. If my expectation was wrong, both Doze mode and Idle should call onResume() after being awakened? I'm kinda confused with these two concepts. Can anyone help me, please?

Yaksa
  • 176
  • 1
  • 12
  • 1
    Doze mode means that you do not use the phone and unplugged it, when idle mode means that you do not use the app. – mrcrambo Nov 25 '20 at 13:27
  • Alright, this makes sense. However, whenever I'm using those first 2 commands of my question, am I forcing idle mode or doze mode? The documentation show the steps for testing the app in doze mode, but it seems to me the steps are showing how to force idle mode. – Yaksa Nov 25 '20 at 15:15

1 Answers1

1

OnCreateView would not be called again after Doze mode ends. OnCreate would only be called if for some reason your app was killed during Doze mode. On Resume is called because you are returning to the activity or fragment after that screen was not in the foreground. I recommend you to read more on the Android lifecycle, and the difference between Oncreate vs on Resume onCreate vs. onResume/onRestart bevhaviour regarding member variables

Chrystian
  • 977
  • 3
  • 11
  • 24
  • So, on testing purposes, when finishing both Idle mode or Doze mode by turning the screen on, onResume will be called? Is there any difference of how those 2 modes work when they are finished? – Yaksa Nov 25 '20 at 14:48