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.
Related
I'm developing a simple phoning application for Android, but I'm having trouble implementing an important functionality.
When I make a call in an Android's default phone app, if I place the phone next to my ear, the screen goes black and it gets temporarily disabled so the user don't accidentally press the virtual buttons.
I already know how to use the proximity sensor, but how can I temporarily disable the screen?
You might want to have a look at these answers
Turn off screen programmatically when face is close the screen on Android
android: turn off screen when close to face
Android: How to turn screen on and off programmatically?
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.
How to create an android app that will appear on the lock screen and can be started even if the phone is lock?
Such that the application icon is visible on the lock screen instead of menu. Similar to emergency calls button on the lock screen.
Can anyone please help me out in this?
I read many things but was not able to find such thing please help me out.
Starting with Android 4.2, you can create lockscreen widgets. If the user places it on the lockscreen, it works mostly like any other widget.
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!
We've got a tablet application for which we want to screen to timeout after a certain period, but would like the user to re-enable it by touching the screen instead of the 'power'-button on the side of the device.
What's the best approach (battery performance) to this?
Using a Partial Wake Lock (will the screen react?)
Disable the screen in some way, but keep everything (including touch response) working?
Other?
Any suggestions on this?
Gabriel,
Since this isn't possible by completely turning the screen off, you may want to just want to use a wake lock and dim the screen to its lowest setting as your 'timeout'. This way you can still accept screen touch events and 'wake' it from this state and bring it back to its previous brightness.
We've got a tablet application for which we want to screen to timeout after a certain period, but would like the user to re-enable it by touching the screen instead of the 'power'-button on the side of the device.
This is impossible except perhaps via custom firmware. If the screen is off, it will not respond to touch events.
Another thing you could do is use an app to turn screen off like ScreenStandby since it works in the background and can start on boot as well.
Out of curiosity, how can we go about contacting someone to help in creating a custom firmware like you did Gabriel?