The issue here (just to reiterate for everyone else) is that there is a bug in the OS that only happens on 5.1 when the device puts itself to sleep. 5.0 does not have this problem. Nor does the upcoming 6.0 that we’ve been testing with. There are 2 naughty things that the OS is doing on 5.1 when the screen goes to sleep…
1) The Android activity doesn’t follow the documented lifecycle. It transitions from running->onStop->onPause which is wrong (pause always comes before stop). This was preventing us from suspending Corona reliably. For this, we’ve added some safeguards to help protect against this in the future to guarantee that you’ll always get an “applicationSuspend” event in Corona; even on 5.1.
http://developer.android.com/reference/android/app/Activity.html#activitylifecycle
2) The ugliest issue only affects OpenGL based Android apps. Google’s GLSurfaceView was wrongly being detached from the activity’s window, which stopped the OpenGL thread that the Corona runtime and its Lua scripts run on, and it also caused the OpenGL context to become invalid. The destruction of the OpenGL context proved to be the final nail in the coffin because it made using OpenGL at that point dangerous and cause crashes in the OpenGL driver on some 5.1 devices. The issue is that we don’t know to suspend Corona until the OS destroys the OpenGL context on us, but that also prevents us from delivering an “applicationSuspend” to Corona reliably since anything you do with the display in Lua has suddenly become dangerous (ie: can cause crashes). So, our final course of action was to avoid the situation all together by preventing the screen from going to sleep.
Now, I’m not particularly happy about this work-around either, but our reasoning here is that this issue only happens on Android 5.1 which, according to Google Play at the time of this posting, is only 5% of the market. It didn’t seem to make sense to put anymore time and resources into this for an OS version that is really just a stepping stone to 6.0, which Google will be pushing hard in the near future. We’d rather put our resources back into proper 6.0 support and dynamic permission handling, which I’m sure Google will demand once 6.0 gets released.
https://developer.android.com/about/dashboards/index.html
Final Note:
Corona’s system.setIdleTimer() will always be false on Android 5.1 You cannot set it true. That’s our work-around.