Android Question Bat Change Intent

Darren Llewellyn

Member
Licensed User
Longtime User
When I use the Extras to string command I get a list of the info and I have numbers for the health, status and Voltage but when I call these up separately with the get extra command they show up as Null, does anyone know why this is? and also where can I get a list of what state the numbers refer to in order to display it in text? thanks
 

Darren Llewellyn

Member
Licensed User
Longtime User
No The code is fine but instead of showing Values for Health Status and Voltage when I use the GetExtras Command It just Shows Null and when I use the ExtrastoString Command I get Values, Also I have no Idea What the Values on the Heath and Status Refer to, the Temperature also seems Really High what scale does That use?
 
Upvote 0

Darren Llewellyn

Member
Licensed User
Longtime User
This is The code to obtain the Extras To String
B4X:
#Region  Project Attributes
    #ApplicationLabel: BatInfoTest
    #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 BatCheck As PhoneEvents
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.
 
    Dim ImgExit As ImageView
    Dim LblBatLvl As Label
    Dim Panel1 As Panel
    Dim LblBatInfo As Label
    Dim BtnWebLink As Button
    Dim ImgPnlBkg As ImageView
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")
    BatCheck.Initialize("BatCheck")
    Activity.LoadLayout("BatCheck")
    Panel1.Initialize("")
    ImgExit.Bitmap = LoadBitmap(File.DirAssets, "geekbot-no2red.gif")
    ImgPnlBkg.Bitmap = LoadBitmap(File.DirAssets, "steel-pasnel-pics.gif")
End Sub
Sub Activity_Resume
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub
 
Sub BatCheck_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
   
    LblBatLvl.Text  = Level & "%"
    LblBatInfo.text = Intent.ExtrasToString
   
   
End Sub
 
Sub ImgExit_Click
    Dim result As Int
    result = Msgbox2("Are you Sure You Want To Exit?", "Close Application", "Yes", "", "No", LoadBitmap(File.DirAssets,"PS-Geekbot-Logo-5.gif"))
        If result = DialogResponse.Positive Then
            Activity.Finish
        Else
            'Exit
        End If
End Sub
Sub BtnWebLink_Click
    Dim p As PhoneIntents
    StartActivity(p.OpenBrowser("http://www.psychostyrene.co.uk"))
End Sub


and This is How I use the Get Extra
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: false
    #ApplicationLabel: GeekBatWidget
    #VersionCode: 1
    #VersionName: 1.1
    #CanInstallToExternalStorage: True
#End Region
 
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim BatCheck As PhoneEvents
    'CRLF - New Line
End Sub
 
Sub Globals
    Dim imgBatLevel As ImageView
    Dim ImgExit As ImageView
    Dim lblBatLvl As Label
    Dim LblPresent As Label
    Dim LblTech As Label
    Dim lblVoltage As Label
    Dim lblStatus As Label
    Dim lblTemp As Label
    Dim lblPlugged As Label
    Dim LblBatInfo As Label
    Dim lblHealth As Label
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    BatCheck.Initialize("BatCheck")
    Activity.LoadLayout("BatLevel")
    ImgExit.Bitmap = LoadBitmap(File.DirAssets, "geekbot-no2red.gif")
End Sub
 
Sub Activity_Resume
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub
Sub BatCheck_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
   
    lblBatLvl.Text  = Level & "%"
    LblTech.text = "Technology - " & Intent.getextra("technology")
    lblTemp.Text = "Temperature - " & Intent.GetExtra("temperature")
    lblVoltage.Text = "Voltage - " & Intent.GetExtra("Voltage")
    lblStatus.Text = "Status - " & Intent.GetExtra("Status")
    lblHealth.text = "Health - " & Intent.GetExtra("Health")
   
    If Plugged = True Then
        imgBatLevel.Bitmap = LoadBitmap(File.DirAssets,"geekbatlogocharge.gif")
        lblPlugged.Text = "Charghing " & Level & "%"
        lblPlugged.TextColor = Colors.Blue
    Else
        lblPlugged.Text = "DisCharghing " & Level & "%"
        If Level >50 Then
            imgBatLevel.Bitmap = LoadBitmap(File.DirAssets,"geekbatlogofull.gif")
            lblPlugged.TextColor = Colors.Green
        Else If Level > 25 Then
            imgBatLevel.Bitmap = LoadBitmap(File.DirAssets,"geekbatlogohalf.gif")
            lblPlugged.TextColor = Colors.Yellow
        Else If Level > 15 Then
            imgBatLevel.Bitmap = LoadBitmap(File.DirAssets,"geekbatlogoquater.gif")
        Else If Level > 0 Then
            imgBatLevel.Bitmap = LoadBitmap(File.DirAssets,"geekbatlogoempty.gif")
            lblPlugged.TextColor = Colors.Red
        Else
            'Do Nothing
        End If
    End If
End Sub
Sub ImgExit_Click
    Dim result As Int
    result = Msgbox2("Are you Sure You Want To Exit?", "Close Application", "Yes", "", "No", LoadBitmap(File.DirAssets,"PS-Geekbot-Logo-5.gif"))
        If result = DialogResponse.Positive Then
            Activity.Finish
        Else
            'Exit
        End If
End Sub

and I have included a Pic of the Output of the Extras To String
 

Attachments

  • pic.png
    pic.png
    38.4 KB · Views: 195
Upvote 0

Darren Llewellyn

Member
Licensed User
Longtime User
well that's Silly I just Noticed I have used Caps on the Three that came Back null Changing Them Has Fixed That issue, But any Help with what the Values of status and Health are would be Really Help Full and What scale the Temperature Uses
 
Upvote 0
Top