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.8 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:
NetworkCapabilities  |  Android Developers API >= 21

LinkProperties  |  Android Developers API >= 21

The extension code is based on this guide:

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 NetworkInfo  |  Android Developers it was deprecated in API level 29.

- Suggestion.

Could someone try this extension on Android 10, Android 11, ...

9 Likes

With companion on Android 11.

@Peter Thanks for try.

1 Like

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 :slight_smile:

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:
checkStateAndPostNotice

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)

I always get " < unknown ssid > ". Can anyone help?

Show your relevant blocks


It always shows " < unknown ssid > ".

If you call this, what output do you get?

image

WiFiTransport return true.

Clarify, the "get transport" got

WiFi, -56,< unknown ssid>

There isn't a "get transport" block...

The extension is unlikely to return an ssid now due to changes in Android security.

Oh... could this work? App Inventor Extensions: WiFi | Pura Vida Apps

See the documentation for getting the ssid:

Might also be the case if you compile to use TransportNet ?

1 Like

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!