How to keep screen from locking but maintain dimming functionality? - android

I would like to be able to keep the android screen from locking in an application. This is not a marketplace application. It is installed on a dedicated tablet.
The only solution I've found is using the Power Manager and using a WakeLock. This way I can keep the screen from locking, but it also keeps the screen from dimming thus wasting battery.
What I would like is for the screen to dim and turn off the way it always does, but that it is able to wake up when touched and not require the user to press the power button and unlock.
Is this even possible? How would you do something like this?

The only solution I've found is using the Power Manager and using a WakeLock. This way I can keep the screen from locking, but it also keeps the screen from dimming thus wasting battery.
You are perhaps using the wrong WakeLock. Please read the PowerManager documentation and try a different WakeLock. There are WakeLock versions that support anything from the screen being off, to the screen being dim, to the screen being normal brightness.
Is this even possible?
If the screen is off, it will not respond to touch events.

Related

Why won't the screen go off when my application is visible?

I've got an app that seems to prevent the screen from turning off when it's visible.
I am not holding any SCREEN_* wakelocks anywhere in the application.
I am holding PARTIAL_WAKE_LOCK for short periods of time (10-20ms). For a particular run I see this wakelock held once and then released, but the screen still stays on indefinitely.
For this test I have set the screen timeout to the shortest possible time (15 seconds) and have disabled keeping the screen on while charging.
If I switch away from my app to anything else, the screen goes off in 15 seconds.
I am not using any kind of XML in my layout resource (as this question suggests to keep the screen on)
I am also not calling getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); as a different answer to the same question suggests.
What other ways could my app be preventing the screen from turning off? This is certainly not the intended behavior!

Android disable lock screen / show when locked

I'm trying to make an android app that can disable the screen when not in use, but can be easily be accessed with out unlocking the phone. The simplest way would be to disable the lock screen I guess. I have tried the disableKeyguard / FLAG_DISMISS_KEYGUARD / FLAG_SHOW_WHEN_LOCKED, but they all appear to no longer be working. My current thinking is that I will need to keep the app from closing, and simply dim the screen, however, since the use case will have the app in use periodically over several hours, I am really looking to avoid this way of doing it.
Is there any way to create an app that can stay active, but sleep when not in use, without requiring an unlock?
Use FLAG_DISMISS_KEYGUARD with FLAG_SHOW_WHEN_LOCKED. If you need to keep the screen on, use FLAG_KEEP_SCREEN_ON. If you need the app to be running while screen is off, use a wakelock.
My friend dim portion is not going to work you because it will still glow in black room and drain battery.
Why don't you just set the application sleep time to 1 second. And on touching back the screen, it will set back to some maximum number for sleep time.

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!

How to prevent an Android application from locking?

I am currently making an Android application in which I need the phone to not lock, so as to avoid the activity losing focus.
I have done a bit of research and found numerous ways to do it including the use of:
Keyguard Manager
Power Manager
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
android:keepScreenOn="true"
I tried using the android:keepScreenOn="true" in my Android manifest, but it seemed to have no effect on the application. I am hesitant to using power manager as every post about it is filled with numerous warnings.
In closing, what is the best way to prevent the Android phone from locking and losing focus of the application? The screen itself may dim or turn off, so long as the application remains in focus and the phone doesn't lock.
What you want can easily achieved by using the PowerManager with a Screen Dim Wake Lock.
Also, IIRC, keepScreenOn is supposed to be added to a widget in an XML file, not in the manifest, if you do decide to use that in the end.

Activate Android with touch instead of power button

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?

Categories

Resources