makis_best Well-Known Member Licensed User Longtime User Nov 9, 2019 #1 Hello Is there any way to know if user use wifi connection or 4G connection? Thank you.
mc73 Well-Known Member Licensed User Longtime User Nov 9, 2019 #2 I usually do it this way, though I'm not sure if it's the best: Code: Copy Dim srv As ServerSocket srv.Initialize(0,"") If srv.GetMyWifiIP = "127.0.0.1" Then log("not connected to WIFI") end if Upvote 0
I usually do it this way, though I'm not sure if it's the best: Code: Copy Dim srv As ServerSocket srv.Initialize(0,"") If srv.GetMyWifiIP = "127.0.0.1" Then log("not connected to WIFI") end if
makis_best Well-Known Member Licensed User Longtime User Nov 11, 2019 #3 Nice approach... I can use the same code to check for 4G connection? Upvote 0
mc73 Well-Known Member Licensed User Longtime User Nov 11, 2019 #4 This is for WiFi. When we're not connected to WiFi, I send a request to a stable link (up, most of the time at least) for e.g. google.com. If I get a success, I assume we are connected using our 4G. Upvote 0
This is for WiFi. When we're not connected to WiFi, I send a request to a stable link (up, most of the time at least) for e.g. google.com. If I get a success, I assume we are connected using our 4G.
Philip Chatzigeorgiadis Active Member Licensed User Longtime User Nov 11, 2019 #5 Check this: Code: Copy Dim myphone As Phone 'Phone Library If myphone.GetSettings ("wifi_on") =1 OR myphone.GetDataState = "CONNECTED" Then Upvote 0
Check this: Code: Copy Dim myphone As Phone 'Phone Library If myphone.GetSettings ("wifi_on") =1 OR myphone.GetDataState = "CONNECTED" Then
makis_best Well-Known Member Licensed User Longtime User Nov 12, 2019 #6 @Philip Chatzigeorgiadis Nice approach... But what about 4G data? Upvote 0
Philip Chatzigeorgiadis Active Member Licensed User Longtime User Nov 12, 2019 #7 makis_best said: @Philip Chatzigeorgiadis Nice approach... But what about 4G data? Click to expand... Sorry, Makis. I haven't use B4A for a few years (doing everything in B4J and ABMaterial these days). The code above is from one of my last projects in B4A, where I checked that a connection was present. I have no clue about how you could check specifically for 4G data connection. Upvote 0
makis_best said: @Philip Chatzigeorgiadis Nice approach... But what about 4G data? Click to expand... Sorry, Makis. I haven't use B4A for a few years (doing everything in B4J and ABMaterial these days). The code above is from one of my last projects in B4A, where I checked that a connection was present. I have no clue about how you could check specifically for 4G data connection.
makis_best Well-Known Member Licensed User Longtime User Nov 12, 2019 #8 It is OK... No problem I am sure I find the solution somewhere in forum Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Nov 13, 2019 #9 You can use Phone.GetNetworkType. Upvote 0
makis_best Well-Known Member Licensed User Longtime User Nov 14, 2019 #10 @Erel you saver... Thank you Upvote 0