Android Question Batterychanged error

stu14t

Active Member
Licensed User
I'm getting an error when I'm checking the battery level

B4X:
java.lang.IllegalArgumentException: method com.coredata.exp.main._pe_batterychanged argument 2 has type int, got null
This is the sub:

B4X:
Sub PE_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
 
    If Level = 15 Then
        Msgbox2Async("The Battery level is down to 15% Consider recharging or replacing the battery!","Core","OK","","",LoadBitmap(File.DirAssets,"Exclamation-icon.png"), False)
    End If
  
    If Level = 5 Then
        Msgbox2Async("The Battery level is down to " & Level & "% You Risk Losing Data. RECHARGE THE BATTERY NOW!","Core","OK","","",LoadBitmap(File.DirAssets,"Exclamation-icon.png"), False)
    End If
    'Log("The battery level is: " & Level)
 
End Sub
I'm targeting API29
 

Brian Dean

Active Member
Licensed User
There is nothing wrong with the code snippet that you posted. It runs perfectly well on my 'phone (after removing the bitmap reference). The problem is somewhere else.
 

stu14t

Active Member
Licensed User
Brian,


My bad, found it. There was a clash with variable I've already assigned to "Scale". Now fixed.
 
Last edited:
Top