How to hide Android app when screen is locked

When running my app on an Android device (Samsung Galaxy S5) and the device gets locked (either by pressing the lock button or waiting for the device to eventually lock it self due to inactivity) my app is still showing. I.e. my app is showing on top of the lock screen, such that to unlock the device I have to quit the app, unlock the screen then reopen my app to continue playing.

How do I ‘hide’ my app when the device gets locked and then show it again once the device has been unlocked? (And why is this not default behaviour?)

I do not have much Android experience and have been looking at something called android.intent.action’s but I have no idea how to configure the Android manifest let alone how to listen for these events inside Unity.

Thanks in advance!

Can you try if it behaves the same both for a "development" build for non-development build? (check/uncheck that checkbox in build settings)

Amazing! As simple as that, once I build for non-development build it works perfectly fine. Thank you.

1 Answer

1

As commented by liortal the ‘problem’ was that I was building for development build and the solution was just to build for non-development build.

that's a workaround, not a fix :)