Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim BroadCast As BroadCastReceiver
End Sub
Sub Service_Create
BroadCast.Initialize("BroadcastReceiver")
BroadCast.addAction("android.net.conn.CONNECTIVITY_CHANGE")
BroadCast.SetPriority(2147483647)
BroadCast.registerReceiver("")
End Sub
Sub BroadcastReceiver_OnReceive (Action As String, i As Object) 'https://www.b4x.com/android/forum/threads/broadcastreceiver.12493/
Dim retIn As Intent
retIn = i
Dim IsConnected As String
'Dim TheType As String
If Action = "android.net.conn.CONNECTIVITY_CHANGE" Then
Dim jo As JavaObject = retIn
Dim NetworkInfo As JavaObject = jo.RunMethod("getParcelableExtra", Array("networkInfo"))
IsConnected = NetworkInfo.RunMethod("getState", Null)
If IsConnected.EqualsIgnoreCase("CONNECTED") Then
'Do this...
Else
'Do that...
End If
End If
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub Service_Destroy
End Sub