Battery Library

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi Everyone,
is there a b4a library that show me the status of the battery and all other information?
Thanks:sign0085:
 

DOM85

Active Member
Licensed User
Longtime User
(Exemple)

Sub Process_Globals
Dim EvenementPhone As PhoneEvents
End Sub
.
.
Sub Activity_Create(FirstTime As Boolean)
EvenementPhone.Initialize("EvenementPhone")
End Sub
.
.
Sub EvenementPhone_BatteryChanged(Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Msgbox("Battery level " & Level & " %", "")
End Sub
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
(Exemple)

Sub Process_Globals
Dim EvenementPhone As PhoneEvents
End Sub
.
.
Sub Activity_Create(FirstTime As Boolean)
EvenementPhone.Initialize("EvenementPhone")
End Sub
.
.
Sub EvenementPhone_BatteryChanged(Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Msgbox("Battery level " & Level & " %", "")
End Sub

Thnk to everyone :D
 
Last edited:
Upvote 0

jota

Active Member
Licensed User
Longtime User
I mean to send the user to that screen, but also would be nice to have the information if possible.
 
Upvote 0

Penko

Active Member
Licensed User
Longtime User
Unfortunately, i am not experienced enough to make it with B4A. The Intent that has to be sent to show the screen is: ACTION_POWER_USAGE_SUMMARY

B4X:
Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);
// check that the Battery app exists on this device
if(resolveInfo != null){
    startActivity(powerUsageIntent);
}

This java source this the trick but I really can't help how to do it in B4A.
 
Upvote 0

dxxxyyyzzz

Member
Licensed User
Longtime User
B4X:
 Dim i As Intent
 i.Initialize( "android.intent.action.POWER_USAGE_SUMMARY", "")
 StartActivity(i)

This should open the battery consumption screen.
 
Upvote 0
Top