TransportNet. Check if the data transport comes via WiFi or Cellular

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.5 KB)

- Blocks.

  • Check if Cellular (Mobile data) is enabled. Return a boolean.
    chequearred2

  • Check if Cellular (Mobile data) is actual transport of data. Return a boolean.
    chequearred3

  • Check if WiFi is actual transport of data. Return a boolean.
    chequearred4

  • Start Event CheckTransport. Return boolean true. There should not be more than one register at a time. Look at the example.
    chequearred5

  • Stop Event CheckTransport. Return boolean false.
    chequearred6

  • 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,-
    chequearred7

  • Gets API of device.
    chequearred8

- Example.

p232_extension_ConsultaRed.aia (12.3 KB)

- Screenshot.

- Other information.

On this website in Spanish you can find more information and updates:
http://kio4.com/appinventor/232_extension_chequear_red.htm

- 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:
https://developer.android.com/training/basics/network-ops/reading-network-state

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, ...

7 Likes

With companion on Android 11.

@Peter Thanks for try.

1 Like