Android disable lock screen / show when locked - android

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.

Related

How do parental control apps lock the screen?

I am developing an app that locks the screen for some time, just like parental control apps do when the screen time runs out. However, I do not really know how they work. I suppose they don't use lockNow because there is that message that shows up telling you that the time has run out. I also don't think they use overlays, because the phone is supposed to detect the use of overlays. So does anybody know what kind of function is used? Also for my app I want to add a button that ends the screen lock, so I am looking for a suitable way to achieve that.

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!

Possible to make setSystemUiVisibility() affect the entire system, rather than just your app?

I was hoping to make an app which dimmed the soft buttons to dots on the Galaxy Nexus, using the code from this answer. For completeness, this is the code:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
Here's the question, is it possible for the app to make this setting system-wide rather than just while the app has focus? So ideally the app would run in the background and would keep View.SYSTEM_UI_FLAG_LOW_PROFILE as the default as long as it's running, for any and every app that you open (unless that app specifically overrides it, I suppose). Is this possible or does this fall outside the realm of what an Android app has permission to do?
A sample use case is this: I use the "Screen Filter" app to reduce brightness a lot for nighttime ebook reading or misc app usage, but the soft buttons are still very bright and distracting, so I wanted to make an app that would dim the soft buttons system-wide while running (like how "Screen Brightness" reduces screen brightness system-wide while running) so this wouldn't be a problem.
As CommonsWare states, it's not possible for an application to change this setting. It's an Activity based setting, that must be set for every single Activity, if you want to make it fullscreen, hide the soft keys, etc.
It's also worth pointing out that you should probably refrain from using it in all your application activities. It's really only meant for games, video players and other applications that need to enter this "low profile" state.
Feel free to accept CommonsWare's answer - I just thought I'd give you a bit of background info on the subject.
is it possible for the app to make this setting system-wide rather than just while the app has focus?
No.

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?

How to keep screen from locking but maintain dimming functionality?

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.

Categories

Resources