How to turn off screen with smart lock Lollipop Pogramatically - android

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.

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.

Is it possible to display some minimum text on android phone screen when phone is asleep?

Is it possible to display some minimum text on android phone screen when phone is asleep programmatically?
Is there a power efficient way to do this?
This is called DayDream mode. Clock, Photos, Quotes etc. can be displayed. Though it seems, DayDream mode should be installed & enabled. I found a tutorial which makes a interactive screen saver.
Please refer-http://code.tutsplus.com/tutorials/android-sdk-create-an-interactive-screen-saver-with-daydream--mobile-16604
Firstly,your question is too vague.
And to answer your question :
Yes its possible to wake the phone from sleep mode using a service.

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

What happens at Screen Lock?

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!

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