KeepAlive (BrightScreen As Boolean) for Android

ashrafidkaidek

Member
Licensed User
Longtime User
In the phone library I have noticed this:
KeepAlive (BrightScreen As Boolean)
Prevents the device from going to sleep.
Call ReleaseKeepAlive to release the power lock.
BrightScreen - Whether to keep the screen bright or dimmed.


What I'm trying to do is to keep the screen on but allowing the screen backlight to dim to save battery, so what should I replace "BrightScreen" with to be able to handle this?

Thank you
 

ashrafidkaidek

Member
Licensed User
Longtime User
Erel,

i have tried the code below, and still the screen and the backlight stays on all the time (i don't want the backlight to stay on, to save battery)

B4X:
Sub Globals
   Dim GPS1 As GPS
   Dim Awake As PhoneWakeState
   Dim BrightScreen As Boolean
End Sub


Sub Activity_Resume
   GPS1.Start(1000,0)
   Awake.KeepAlive(BrightScreen = False)
End Sub


is there anything i'm doing wrong here?

Thank you
 
Upvote 0

ssg

Well-Known Member
Licensed User
Longtime User
Erel,

i have tried the code below, and still the screen and the backlight stays on all the time (i don't want the backlight to stay on, to save battery)

B4X:
Sub Globals
   Dim GPS1 As GPS
   Dim Awake As PhoneWakeState
   Dim BrightScreen As Boolean
End Sub


Sub Activity_Resume
   GPS1.Start(1000,0)
   Awake.KeepAlive(BrightScreen = False)
End Sub


is there anything i'm doing wrong here?

Thank you

Hi,

I am not sure if this answers your question, but i think the problem is with the following line (havent tested it yet):

Awake.KeepAlive(BrightScreen = False)

BrightScreen by default will be false... when you use it in the above situation, it is being compared, thus bringtscreen (which is false) = false will return true. Keep alive is therefore true.

I'd change it to this:

BrightScreen = False
Awake.KeepAlive(BrightScreen)

Hope that works!

Cheers!
 
Upvote 0

ashrafidkaidek

Member
Licensed User
Longtime User
Erel, yes I’m using the updated library (1.31)

SSG, thank you for your reply, I actually thought about it before, but after I tried it nothing changed.

I actually tried to look for the backlight setting in my device to see if it’s causing the problem, but unfortunately I couldn’t find an option to change it! So I’m going to do more research about it. I will write an update once I get more info.

In the mean while it will be great if anybody else experience same issue to let us know through this thread

Thank you
 
Upvote 0

brainfart

Member
Licensed User
Longtime User
Hello.
Is the BrightScreen being ignored been fixed?
I have an application that requires the screen to stay bright all the time.
User will be warned about the consequences like battery life and to plug the device in.
In my code the BrightScreen is set to true yet the device dims after "screen timeout" set in display settings.
:sign0161:
 
Upvote 0

brainfart

Member
Licensed User
Longtime User
I am using Samsung Infuse SGH-I997 from AT&T.
FW: 2.2.1 Kernel: 2.6.32.9 FROYO.UCKE3

B4A Library: Phone 1.55

Phone does keep awake but screen goes dimmer after a while.

Code:

B4X:
Sub ScreenB
    phone1.SetScreenBrightness(Brght)    'screen brightness from variable
    Awake.KeepAlive(BrightScreen = True)
End Sub
 
Upvote 0

brainfart

Member
Licensed User
Longtime User
:sign0161:

That is why I picked this username.
That is what you get when you copy and paste code from a thread message that did not work to start with.
I mean earlier in this thread.

Thanks Erel.
 
Upvote 0
Top