By means of this extension we can check if the internet data comes to us through WiFi or through the data network (Mobile data. Cellular). We can also get if "Mobile data" is enabled.
It works with API >= 21
Tested on Android 9.
- Extension.
com.KIO4_TransportNet.aix (11.8 KB)
- Blocks.
Check if Cellular (Mobile data) is enabled . Return a boolean.
Check if Cellular (Mobile data) is actual transport of data. Return a boolean.
Check if WiFi is actual transport of data. Return a boolean.
Start Event CheckTransport . Return boolean true . There should not be more than one register at a time. Look at the example.
Stop Event CheckTransport . Return boolean false .
If transport is WiFi , gets this String: WiFi,SignalStrength,"SSID"
If transport is Cellular , gets this String: Cellular,0,NameOperator
If it does not transport by WiFi or Cellular, gets this String: -,0,-
Gets API of device.
- Example.
p232_extension_ConsultaRed.aia (12.3 KB)
- Screenshot.
- Other information.
On this website in Spanish you can find more information and updates:
- Code.
This extension uses:
https://developer.android.com/reference/android/net/NetworkCapabilities API >= 21
https://developer.android.com/reference/android/net/LinkProperties API >= 21
The extension code is based on this guide:
This document explains how Android applications can monitor and respond to dynamic changes in network connectivity using `ConnectivityManager` and `NetworkCallback` to get real-time updates on network status, capabilities, and properties.
I have use the nomenclature "Transport" and "Cellular" because it is the one that uses this class (TRANSPORT_CELLULAR).
There are other similar extensions but they don't work with API 29 as they seem to use https://developer.android.com/reference/android/net/NetworkInfo it was deprecated in API level 29.
- Suggestion.
Could someone try this extension on Android 10, Android 11, ...
9 Likes
Peter
June 8, 2021, 4:46pm
4
With companion on Android 11.
I am confused by the result I am seeing from the TransportNet Extension (TransportNet. Check if the data transport comes via WiFi or Cellular ). I suspect this is due to my lack of understanding or expectation rather than a bug
The test app (attached below) checks each of the states:
(WiFiTransport, CellularEnabled, and CellularTransport) from a clock timer event and reports the results with a Notifier Alert.
The check and post procedure:
The clock timer event:
With WiFi off and Cellular data on, I get the following. First, with the app screen active, the alert makes sense: the transport is Cellular and not WiFi and Cellular is enabled:
However on other screens, such as the following browser, the Cellular Transport indicates False:
So far I have only tested this on Android 8 (moto e5 play). Later today I can check on Android 13 (galaxy A14).
Thankful for any help or comments,
Randal
TransportNet_Test.aia (24.1 KB)
fhchiu
April 17, 2024, 2:25pm
8
I always get " < unknown ssid > ". Can anyone help?
TIMAI2
April 17, 2024, 2:52pm
9
Show your relevant blocks
fhchiu
April 17, 2024, 3:02pm
10
It always shows " < unknown ssid > ".
TIMAI2
April 17, 2024, 3:09pm
11
If you call this, what output do you get?
fhchiu
April 18, 2024, 8:35am
12
WiFiTransport return true.
Clarify, the "get transport" got
WiFi, -56,< unknown ssid>
TIMAI2
April 18, 2024, 9:57am
13
There isn't a "get transport" block...
The extension is unlikely to return an ssid now due to changes in Android security.
fhchiu
April 18, 2024, 10:08am
14
TIMAI2
April 18, 2024, 10:10am
15
See the documentation for getting the ssid:
Might also be the case if you compile to use TransportNet ?
1 Like
fhchiu
April 18, 2024, 10:43am
17
It seems ok using Taifun. I use the build-in blocks to enable ACCESS_FINE_LOCATION like How do I force a permission to be granted?
Then I tried TransportNet it also work.
Thank you very much!