I am reading the Battery and Connection information.
In my Starter I have:
In Activity("Main") I have:
I keep getting the following error:
The error occurs here:
In my Starter I have:
B4X:
Sub Process_Globals
Dim PE As PhoneEvents
End Sub
Sub PE_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
CallSub2(Main, "ConnectionChanged", State)
Log("ConnectivityChanged: " & NetworkType & ", state = " & State)
Log(Intent.ExtrasToString)
End Sub
Sub PE_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
CallSub2(Main, "BatteryChanged", Level)
Log("BatteryChanged: Level = " & Level & ", Scale = " & Scale & ", Plugged = " & Plugged)
End Sub
In Activity("Main") I have:
B4X:
Sub ConnectionChanged(State As String)
lblWifi.Text = State
End Sub
Sub BatteryChanged(Level As Int)
lblBattery.Text = Level
End Sub
B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ConnectivityChanged: WIFI, state = DISCONNECTED
Bundle[{networkInfo=[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false], networkType=1, inetCondition=0, extraInfo=<unknown ssid>}]
Error occurred on line: 37 (Starter)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:857)
at b4a.example.starter._pe_batterychanged(starter.java:156)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.phone.PhoneEvents$ActionHandler$1.run(PhoneEvents.java:321)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub BatteryChanged signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:333)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:282)
... 22 more
Caused by: java.lang.Exception: Sub BatteryChanged signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 23 more
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
The error occurs here:
B4X:
CallSub2(Main, "BatteryChanged", Level)