switch backlight off

Flosch

Member
Licensed User
Hi i'm writing a app where the screen has to be shown all the time.
To get this I use phone.KeepAlive(False) - works great.

Now I want to greate a energy management:
After 20 seconds the screen brightness should get down to 30%
I use ph.SetScreenBrightness(0.3) - works also fine.

After 5 minutes the Backlight should turn off.
(I know this function from my Navi-App CoPilot)
You are still able to see something but it's quite hard.
You are also able to press buttons etc.

I tried to use ph.SetScreenBrightness(0) but then the monitor turns off and the phone doesn't react on the menue- or back-button or to any button on the screen.

I also tried to set the brightness very low but it is still to bright or I get the mode the phone will not react.

So I have two questions:
Is it possible to turn the Backlight off.
And which mode i will get when the brightness is set to 0?
 

NeoTechni

Well-Known Member
Licensed User
I'm having problems with this too

I tried setting the brightness to 0, but that locks up the system.
I tried releasing the wake lock, but that only lets me turn the screen off if I finish/close the activity.
There has to be a way to turn the screen off immediately, and back on again
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
You can turn off the screen but then it will not react to user interactions.

I'm trying to get it to turn off when the proximity sensor goes off, specifically so it wont respond to touch. I currently turn brightness down to 1/55 but the device still gets hot.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
I already disable input. What I need is the screen completely off.

I release the wakelock, but it wont turn off till I force my activity to close.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Did someone ever find how to turn the screen off? or the back light?

I know that when the screen is off the only way to turn it on is the 'hard power' button and that's really not OK.

I am thinking from what I have read that dimming the screen and covering it with a black panel is the best bet.

How did other people handle this? Just dim it all the way down?
 
Upvote 0

wes58

Active Member
Licensed User
Have a look there: http://android.stackexchange.com/qu...rn-off-screen-without-affecting-anything-elseI
I haven't tried it but if you have a rooted device you can try it
B4X:
Depending on your kernel it might be possible to turn the brightness off your screen to 0 via t he appropriate sysfs file.

On a Sony Xperia Acro S currently running a custom AOSP-Based 4.2.2 ROM (SlimBean 6.2) i found the following:
130|shell@android:/ # find /sys/ -name brightness
...
/sys/devices/i2c-3/3-0040/leds/lcd-backlight/brightness
...

the following command turns my screen off but keeps the apps running:
echo 0 > /sys/devices/i2c-3/3-0040/leds/lcd-backlight/brightness

if you combine this with an app which keeps the wakelock for your device, you should be fine.

You will have a different result from the "find" command.
 
Upvote 0

camolas

Member
Licensed User
It works for me in terminal
B4X:
echo 0 > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness
now whe need help to pass this to B4a
 
Upvote 0

camolas

Member
Licensed User
Solved:

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim Ph As Phone
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", "echo 0 > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness" & CRLF & "exit") 'Any commands via crlf, and exit at end
StdOut.Initialize
StdErr.Initialize
Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
'Msgbox(StdOut.tostring, "")
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Thanks to m0narX and wes58 example :)
 
Last edited:
Upvote 0
Top