J jefflynn1974 Member Licensed User Longtime User Dec 7, 2013 #1 Is there any method to check the mobile connection (dataconnection) is enabled or not? I found a lot of ways but all of them gived back fake datas if the WiFi was ON. Any ideas or I can't do anything with this?
Is there any method to check the mobile connection (dataconnection) is enabled or not? I found a lot of ways but all of them gived back fake datas if the WiFi was ON. Any ideas or I can't do anything with this?
Erel B4X founder Staff member Licensed User Longtime User Dec 8, 2013 #2 Have you tried Phone.GetNetworkType? It should return "UNKNOWN" if there is no connection. Upvote 0
J jefflynn1974 Member Licensed User Longtime User Dec 8, 2013 #3 Erel said: Have you tried Phone.GetNetworkType? It should return "UNKNOWN" if there is no connection. Click to expand... Unfortunately it only gives back the cellular type. If I turn off the mobile connection it also say "HSPAP" or another type... Upvote 0
Erel said: Have you tried Phone.GetNetworkType? It should return "UNKNOWN" if there is no connection. Click to expand... Unfortunately it only gives back the cellular type. If I turn off the mobile connection it also say "HSPAP" or another type...
Erel B4X founder Staff member Licensed User Longtime User Dec 8, 2013 #4 You can use this code: Code: Copy Sub MobileDataEnabled As Boolean Dim r As Reflector r.Target = r.GetContext r.Target = r.RunMethod2("getSystemService", "connectivity", "java.lang.String") Return r.RunMethod("getMobileDataEnabled") End Sub Add this line to the manifest editor: Code: Copy AddPermission(android.permission.ACCESS_NETWORK_STATE) Note that it calls a hidden API. This means that it might be removed in a future version of Android. Upvote 0
You can use this code: Code: Copy Sub MobileDataEnabled As Boolean Dim r As Reflector r.Target = r.GetContext r.Target = r.RunMethod2("getSystemService", "connectivity", "java.lang.String") Return r.RunMethod("getMobileDataEnabled") End Sub Add this line to the manifest editor: Code: Copy AddPermission(android.permission.ACCESS_NETWORK_STATE) Note that it calls a hidden API. This means that it might be removed in a future version of Android.