============= MANIFEST =====================
============add CheckWifi service ==================
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddReceiverText(CheckWifi,
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>)
AddPermission (android.permission.ACCESS_NETWORK_STATE)
AddPermission (android.permission.ACCESS_WIFI_STATE)
============add CheckWifi service ==================
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim R As Reflector
End Sub
Sub GetWIFIType As String
'Requires Permission to be added with the Manifest Editor:
' AddPermission (android.permission.ACCESS_NETWORK_STATE)
R.Target=R.GetContext
Try
R.Target=r.RunMethod2("getSystemService","connectivity","java.lang.String")
R.Target=R.RunMethod("getActiveNetworkInfo")
R.Target=R.RunMethod("getTypeName")
Return R.Target
Catch
Return "none"
End Try
End Sub
Sub GetWIFIName As String
'Requires Permission to be added with the Manifest Editor:
' AddPermission (android.permission.ACCESS_NETWORK_STATE)
R.Target=R.GetContext
Try
R.Target=r.RunMethod2("getSystemService","wifi","java.lang.String")
R.Target=R.RunMethod("getConnectionInfo")
R.Target=R.RunMethod("getSSID")
Return R.Target
Catch
Return "none"
End Try
End Sub
Sub Service_Create
End Sub
Sub Service_Start(startingIntent As Intent)
Dim ConnectionType As String =GetWIFIType
If startingIntent.Action = "android.net.conn.CONNECTIVITY_CHANGE" Then
ToastMessageShow("xxxxxxxxx wifichanged-Connection Type:" & ConnectionType & _
" WifiName:" & GetWIFIName, True)
End If
End Sub