Switch screen on by application (ANDROID, debug, all rights possible) - android

I read all there is about wake locks and so on. But I want something different. I have three devices to test, and mainly one device sucks really hard. Its the Asus transformer. The main problem, it can't be charged over USB. This means, if I tell it to "stay enabled during debug" the battery is dead after a while.
Also I want to write a small script deploying my app to all three devices once I build (no problem), starting them (no problem), and then ENABLE THE SCREEN (no way till now).
If found this intent, was happy for 23.5 seconds, and then read this:
http://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_ON
Is there any way for me to enable the screen. The device is black, the screen is locked, my app starts (this works, seeing debug messages and hear startup sound), but i would have to manually unlock the screen.
I know, its not THAT bad, but when developing UIs I would have to do this like 100 times a day, and this is annyoing. The two little ones could stay on, but the big one (Transformer) would be empty after a while. I just had a thought, maybe I can tell the Transformer only to dim after a while, and to "undim" on startup. Would increase lifetime tenfold.
But still, if anyone knows a way to turn the screen on, that would be fantastic!
Chris
[UPDATE]
Ok, what you can do is reduce the screen brightness after some time, by using this:
WindowManager.LayoutParams WMLP = getWindow().getAttributes();
WMLP.screenBrightness = 0.01F;
getWindow().setAttributes(WMLP);
Dont use 0 as a value (at least not until this question is answered), because the screen will switch off, and you will never get in on again. At least without using your thumb and pressing a button, sooo oldschool...

Related

How can I prevent Android Wear leaving ambient mode and going black after several minutes

I am trying to program a bedside clock like the Moto 360's showing the time during the night while charging.
Therefore I have set up an "Always-On-App" with alarm manager according to https://developer.android.com/training/wearables/apps/always-on.html#BackwardCompatibility which works basically as intended (Android 7.1.1 Wearable Activity on a "Diesel On Full Guard").
However after several minutes lying still on the desk, the watch is leaving ambient mode (my preferred mode during night time) and switching its screen off.
I've already tried using a wake lock according to Android Wear: measuring sensors and preventing ambient mode / sleep but with no success. The processor may still be working, but the screen goes black after a while (very bothersome to debug as you always have to wait and can't reproduce on the emulator, which never switches off).
So how can I prevent the watch from leaving ambient mode onto the direction "off", or at least detect that state and switch it back on?
Your watch probably has ro.ambient.plugged_timeout_min set to some positive value (see the reddit post here). It's meant for protecting the OLED screen from burn in. If you run adb shell dumpsys alarm you can see a wake alarm for com.google.android.wearable.ambient with the action com.google.android.wearable.action.STOP_AMBIENT_DREAM that will turn the screen off/doze device after the timeout mentioned above.
My best guess is that to prevent it from going to ambient you'd need to either
Stop it from going into ambient entirely, i.e holding a SCREEN_DIM_WAKELOCK or similar, and using an entirely black background.
Periodically wake the screen up so that the timeout resets. This is probably suboptimal if it's meant as a night clock though.

Android 5.0 - how to wake up device display? Scienctific app

Question
Since there is only one Wake-Lock left with 5.0, what is the way to force the device to go out of standby for 2-5 Seconds and then go back black. No interaction, no unlock of keys... just out of standby. All solutions I found work with deprecated Wake-Locks.
I know it´s a bad idea and Google want to forbid it to me... do this for normal apps makes sense, but I work on a scientific app where I need it and can risk the battery drain.
Can I force a deprecated wake lock to work under a newer OS?
Why I need this?/What I do/2 Devices == Different behavoíour
I have a step counter, write the values to a sqlite db - at a alarm i look to the db and ask for the steps. based on this I do some magic.
Sony: With the Sony Xperia Z1 compact it works, because they don´t stop the sensors while Standby. So no batching.
Samsung: Same app, also step counter as sensor. But here I always get 0 steps when I ask for them in my alarm. A workaround: When I start the device out of standby for a moment and go to black again. My alarm can get the right value. And this is what I need. So I want to activate the display before I ask for the steps. Then the batched sensor data must be in the db and I get the right steps.
So any solutions? Wake-Locks over the service runtime, where my step counter is inside, are not working.
Big thank you, and I am sure for this case there is no duplicate Question. Get points and make me happy. Big Thank you for your help!

I need creative advice for getting my Desire HD to work again

Here's the idea. I have a HTC Desire HD phone, rooted, custom rom (JellyTime 4.2.2) installed. This is the second time this has happened:
After a phone restart, phone gets stuck when loading on splash screen. I see the animation, then it stops, but splash screen stays for infinity amount of time. Last time this has happened I had android debugging on, I used android-sdk for adb reboot recovery. And got it working again, but this time I wasn't cautious, and I don't have the debugging enabled. You might ask Why not go into recovery mode using power+volume combination? Well, I can't. My volume - button is broken. So here I am, with a stuck phone, with no apparent way to reach recovery mode. Any suggestions, guys? I'd be grateful.
EDIT: I was asked to define broken. The button IS missing, but even without being missing, the bottom button simply doesn't react when you click it mechanically.
By holding the volume up I was able to get to fastboot, and then I entered my recovery mode.

Air for Android: Black Screen after device-alarm

I do have a problem and have very little to go on. I'm about to release an App (created with Air for Android As3) on the Samsung App Store and just got a list of issues that have to be resolved after the app has been tested by samsung staff before the app could be released.
I did manage to solve almost all of the issues, but 1 very important one is beyond me. They say the screen turns/stays black, when returning after the device alarm interrupted the app. This issue practivally happend on all their devices, including a group including the phones I own (e.g. Galaxy S3).
I do have "OnDeActivate" and "OnActivate" listeners in place that are there to pause the app, disable sound etc. if it loses focus, gets minimized etc., yet I checked on my devices and I can't reproduce this error. Meaning if the app gets interrupted on my device by the alarm, I can resume it without any problems. no black screens.
So the question is: Is there any way for me to fix that at all? I do have to work within AirForAndroid AS3 so I guess possibilities are limited. Any clues where I can look? Any listeners to set, or is there a way to maybe "force" the app to reinitialize or refresh the display? Or to listen for the system alarm? Help would be much appreciated. Thanks in advance!
I am trying to overcome the same issue, I read somewhere that setting the stage quality to something else on both the activate and deactivate events might solve the issue.
So just set your stage quality to medium or whatever different in the deactivate and set it back to what it needs to be in the activate.
This should make AIR snap out of that black screen for the alarm (I hope)
An app of mine is with this fix is currently undergoing testing on the Samsung App Store.
I hope it fixes it.
Good news, the dirty fix of toggling the stage quality seems to have worked for Samsung, it has not shown up in their latest certification report of my app.
by the way, this is not for a stage3D app, that's different
It's for a GPU app
When the app loses focus on Android (goes into background) it will lose the context, which among other things mean that you lose all the created graphics, cached objects and like.
You didn't specify what kind of app it is. If you're using Stage3D, that means you'll have to recreate all your textures, and if you're on plain old displaylist, you'll have to recreate any bitmaps that were created at runtime, and redraw your screen at least once (so the vector graphics get redrawn too).
Now, if you're using Starling, for example, it can take care of recreating context for you (there's a flag for enabling that), although you'll still have to recreate dynamically created bitmaps.

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