What happens at Screen Lock? - android

I am working with Camera API to develop an android app. I use flash in this app and I need it to be ON all the time. I managed to turn flash ON at start, and after onResume() is called, but I can't figure out what to do after a screen lock. When I lock my screen and then unlock it, flash doesnt turn ON.
I need to understand how to manage that and turn flash ON after unlocking the screen if the app is running(not onPause()).
Any reference or advice is welcome! Thanks in advance!

Related

How to lock/unlock phone from Service in android?

I want to lock/unlock android using a service. I have checked other questions but none works. Some require to have my app in foreground and some I don't understand well enough. I want to show the lock screen if the device is password locked else home screen.
Just Turning screen on and off only will also work. Anyone know how to do it?
Edit 1:
I have tried things and managed to turn on(WakeLock) and off(DevicePolicyManager) screen. However, turning off screen does not lock phone only turns off the display. I use locknow(). This is acceptable but if possible can anyone tell how to lock phone?
Edit 2:
I can not lock my phone even by using physical lock button. It just turns off the screen.

cocos2dx android app doesn't lock the screen after inactivity

I ported my Cocos2dx game from iOS to Android. Everything works fine, but there is something strange on lock screen on android. The application doesn't lock the screen after inactivity.
I try to change SCREEN_OFF_TIMEOUT programmatically from my app. It changes, but not to my application.
I found on stackoverflow tips on calculating idle time, and then lock the screen programmatically. Is the only way? Is the screen should not be blocked automatically?
Hi try to call method setKeepScreenOn(false) in your cocos2d-x activity, which call method in Cocos2dxActivity.java This will allow game to sleep. After some time, if you have screen lock set in your phone settings will lock the screen.
setKeepScreenOn(true) function that prevent phone to sleep, useful for some
games

How to turn off screen with smart lock Lollipop Pogramatically

Is there any way to lock the phone or turn the screen off and make it work with smart lock the next time I turn it on?
If I turn it off programatically the next time that I turn on the screen it dosen't start any smart lock process and looks like I didn't have the smart lock on.
Thanks
You can't do that currently. Using DevicePolicyManager.lockNow() to turn off the screen and lock the device crashes the GoogleTrustAgent. There is an open issue for this bug at the Android Open Source Project see Issue 79735. Hope it will be fixed soon.

FLAG_KEEP_SCREEN_ON does not work during keygaurd lock

Hi I am an Android newbie, I want to create an app which stays displayed even if the power button is pressed, I used,
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
but I had to press power button again to display the app, someone suggested me to use,
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
but it doesn't seem to work. Is there any work around ?
You can't prevent hardware keys overriding. Power button works on hardware level. Ur app will be unable to turn screen on after it was turned off by hardware.

Turn off device screen (without locking it)?

I'm making an app that uses the Proximity Sensor while a phone call is in progress. My main issue is that the device doesn't turn the screen off when I hold it up against my face (while talking on the phone). If anyone has a solution as to how to fix this, then my problem will be solved.
Right now though, I'm trying to manually switch the screen off to imitate the normal behavior of the phone app. I looked through a lot of other posts about this but most of them seem to have instructions on how to keep the screen turned ON. My case is the exact opposite... how do I programmatically set the device to turn it's screen off? I don't want it to lock itself or sleep (since the phone call will still be in progress), just turn the screen completely off.
Thanks!

Categories

Resources