How to detect backlight is on? - android

My application requires resource and drains a battery when it is working. So, I want to know the way that user is not available on the phone.
Is there a way to use the built in power save mode on the blackberry to where if the screen dims to suspend the application works active and when the user wakes the device back up with a keypress or trackball movement to resume the application works active?
Thanks in advance.

Is there a way to use the built in
power save mode on the blackberry to
where if the screen dims to suspend
the application works active and when
the user wakes the device back up with
a keypress or trackball movement to
resume the application works active?
This happens automatically, with no code changes required. Unless something is holding a WakeLock, the CPU will turn off sometime after the screen goes dark. The CPU will turn back on when the user presses the power button.

Related

How do I keep my camera active on Android even when the phone is locked and screen sleeps?

When I play Ingress, Ingress remains active. Even when my screen goes black, if I push the power button, Ingress is still active. I do not need to unlock my phone nor wait for it to "wake up". (The phone is locked though - to use any other app I need to unlock the phone.)
How do I get the same functionality for my camera app?
If I'm using the phone as a camera, with the camera app active, if the screen goes black, when I hit the power button, I want the camera to be open and active.
Things I've tried:
* Keeping my phone unlocked when in paired to a trusted Bluetooth advice. Then when I push the power button, I get a screen where I have to swipe to wake it up. With Ingress, I don't have to swipe the screen nor wait for anything.
* Snapshot. I've tried using the Snapshot app, but I have to wait for the phone to launch the camera app.
* The camera on swipe from the lock screen ... and again I have to wait for the camera app to launch.
I'm willing to figure out how to build my own app if needed. (But would rather find something.)
I'm willing to take a battery hit.

Capturing touch events even while system is in sleep

I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen, I tried searching for a solution but it is hard to find one.
Should I want to set any permissions or is there any inbuilt methods or can I override any methods to perform this functionality.
I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen
Fortunately, this is not possible. Otherwise, the device would not be asleep, and battery life would suffer as a result.
Here is a link that shows how to prevent the phone from sleeping.
If you couple that with, say a black screen to 'pretend' the hone is sleeping but actually running your code. So your code can still intercept touch event
Then you need to install your app as a service and make it start when the device is turned on.
You will not need NDK or rooted device for that (sorry, got a short night :) )

android: standby button, the touch locks and the phone remains active

I would like to make an application when it is activated by pressing the standby button, the touch locks and the phone remains active . Which method should I use to do this and to take control of the standby button?
Which method should I use to do this and to take control of the standby button?
Fortunately, this is not supported by Android, for obvious security reasons. Apps could use this to prevent people from turning off their phones, for example.

Is it possible to get a device to wake up from sleep (screen dark) by detecting a touch to the screen?

I want to get an android device to wake up from sleep or however the state in which the phone gets after a certain amount of inactivity when the screen goes dark, by detecting a touch to the screen instead of clicking on any button.
In the documentation the only thing I have found is the FLAG_TOUCHABLE_WHEN_WAKING flag in WindowManager.LayoutParams and it says:
Window flag: When set, if the device is asleep when the touch screen
is pressed, you will receive this
first touch event. Usually the first
touch event is consumed by the system
since the user can not see what they
are pressing on.
I thought that meant that if the device's screen is turned off and that flag is set for an Activity then it will wake up to the touch (which is what I want it to do). Am I misunderstanding the purpose of this flag? Are there additional implementation details I'm ignoring? Is there some other way?
Am I misunderstanding the purpose of this flag?
AFAIK, yes. There is a slice of time between when the screen turns off and when the device falls asleep. During this time, if the user touches the screen someplace where the window has this flag, the screen turns on again and the inactivity timer is reset.
I can find no other use of this flag in the Android source code.
Is there some other way?
No. If the device is asleep, touch screen events are not registered.

How to shield the home key if my app is active? (Screensaver, Lockscreen)

If I want to write a Screensaver or Lockscreen. Is there a way to prevent the home key from going back to the launcher?
Simple: when you enter the activity, call
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
and when you exit the activity, call
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION);
Taking over the home key is an Android no-no.
The only screensaver in Android should be the screen going off. Why would anyone want to run down their battery instead of just pressing one button to turn the screen off and doing the same to turn it back on? It just doesn't make sense on a device with a very limited power supply to run a screensaver.
I'm not quite sure but from what I have read online, custom lock screens can only be done in custom firmware or rooted applications.

Categories

Resources