App Inventor Extensions: WiFi | Pura Vida Apps

App Inventor Extensions


WiFi Manager Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor community. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Dec 22th, 2015: Version 1: initial release.

July 7th, 2016: Version 2: macAddress method added.

Aug 11th, 2016: Version 2a: avoid DX execution failed error: build each extension separately

Nov 27th, 2016: Version 3: BSSID method added

Feb 25th, 2017: Version 3a: bugfix IllegalArgumentException: Receiver not registered: null while switching screens

May 10th, 2017: Version 3b: bugfix IllegalArgumentException: Receiver not registered while switching screens

Aug 14th, 2017: Version 4: correspondingRSSIs, SignalStrength, ConnectionInfo, Is5GHzBandSupported added

Aug 16th, 2017: Version 5: correspondingBSSIs added

Dec 6th, 2017: Version 5a: bugfix configuredSSIDs, see also here. Thank you Edgar for the error report.

Dec 14th, 2017: Version 5b: bugfix ConnectSSID, see also here. Thank you again Edgar for the error report.

Apr 8th, 2018: Version 6: new method AccessPointIP added

Apr 13th, 2018: Version 7: connect without password

Aug 29th, 2018: Version 8: Disconnect method added

Nov 6th, 2018: Version 9: Dnsservers method added

Jan 23th, 2019: Version 10: SDK 26 update: dangerous permission android.permission.ACCESS_COARSE_LOCATION removed. What is a dangerous permission? The method AvailableSSIDs including its corresponding event have been removed.

Jan 28th, 2019: Version 11: AvailableSSIDs added again. Additionally example project provided about how to use it together with the location sensor and GPS enabled.

Oct 21th, 2019: Version 12: AfterWifiNegotiation event added

Oct 21th, 2019: Version 13: RemoveSSID added

Oct 21th, 2019: Version 14: LocalIP: returns wifi ip if its enabled else the cellular one

May 25th, 2021: Version 14 recompiled, see also here.

Nov 12th, 2021: Version 15: android.permission.ACCESS_NETWORK_STATE added for App Inventor nb188 release, see also here.

Aug 31st, 2023: Version 16: ACCESS_FINE_LOCATION and WRITE_SETTINGS permissions added,
ConnectSSID method for Android >= 10 uses the network request API, see also here
HaveSystemWritePermission and ApiLevel methods added,
IsGpsEnabled, IsLocationPermissionGranted and RequestLocationPermission method added,
MacAddress method removed, does not work for Android M, see also here
RemoveSSID method removed, suppressWarning properties replaced by ErrorOccurred event

Note: this version of the extension is not compatible with earlier versions. You therefore have to remove the extension from your project and then import it as new extension.

Dec 10th, 2023: Version 16a: Extension rebuilt to avoid "ERROR: DX returned an error code" for projects, having 2 extensions or more which use proguard to obfuscate their code, see also Pull request 3004.

Mar 20th, 2024: Version 17: methods for Network Suggestion API added. Sponsor of version 17 is Santipong. Thank you Santipong!

Description

Some useful blocks to use in a wireless lan.
Required permissions: android.permission.ACCESS_WIFI_STATE, android.permission.CHANGE_WIFI_STATE, android.permission.ACCESS_NETWORK_STATE, android.permission.ACCESS_FINE_LOCATION, android.permission.WRITE_SETTINGS

Properties


Returns whether Success Message should be suppressed.


Specifies whether Success Message should be suppressed.

Methods


Return the local IP Address. Returns wifi ip if its enabled else the cellular one.
Sponsor of this block is Marius. Thank you!


Return the MAC Address of the device.
Sponsor of this block is Niko. Thank you!


Get current WiFi state: true or false.


Enable WiFi.
You can hide the success message after setting the suppressSuccessMessage property to false.
Note: starting from Android 10, it is not possible anymore to enable Wifi programmatically, see also this stackoverflow answer, therefore a dialog for the user will be provided, see also this Activity Starter solution.


Disable WiFi.
You can hide the success message after setting the suppressSuccessMessage property to false.
Note: starting from Android 10, it is not possible anymore to disable Wifi programmatically, see also this stackoverflow answer, therefore a dialog for the user will be provided, see also this Activity Starter solution.


Get current WiFi SSID (Service Set Identifier).

Note: to be able to test this block, you have to build the app, because the permission CHANGE_WIFI_STATE is not available in the companion app.

Note: Precondition to use this method is to grant location permission. Also GPS must be enabled. See the example project about how to use it..


Get current WiFi BSSID (the MAC address of the access point).
Thank you burrowmoor for being the sponsor of this method.

Note: to be able to test this block, you have to build the app, because the permission CHANGE_WIFI_STATE is not available in the companion app.

Note: Precondition to use this method is to grant location permission. Also GPS must be enabled. See the example project about how to use it..


Get a list of available SSIDs (Service Set Identifiers). WiFi must be enabled for this.

Note: to be able to test this block, you have to build the app, because the permission CHANGE_WIFI_STATE is not available in the companion app.

Note: Precondition to use this method is to grant location permission. Also GPS must be enabled. See the example project about how to use it..

Note: Android will get more and more restricted. In a future Android release the AvailableSSIDs method will stop working, see also this note in the Android documentation: "The ability for apps to trigger scan requests will be removed in a future release."


Get current connection info.
For details, see also WiFiInfo documentation.


Check, if 5 GHz Band is supported. Returns true or false.


Get signal strength (RSSI) in a range between 0 and 100.
This algorithm is used to calculate the signal strength..


Get IP address of the access point.
Thank you Eric for being the sponsor of this method.


Return a list of DNS servers (primary and secondary) of the current network.
Note: The method returns the IP address of the gateway router when DNS is not configured inside the router.
Thank you Gabriel for being the sponsor of this method.


Returns the API Level of the device.


Returns true, if location permission have been granted.


Request location permission. Required for SSID, BSSID, AvailableSSIDs methods.

What is the difference between the Network Request API and the Network Suggestion API?

Please see the official Android documentation.

Network Request API


Connect to a SSID (Service Set Identifier). Available for Android >= 10.
The new peer to peer API to bootstrap configuration for secondary devices is used, which is available starting from Android 10, see also here. This API requires the permission WRITE_SETTIMGS.

Note: Creating a connection using this API does not provide an internet connection to the app or to the device!!!

Bypassing user approval
Once the user approves a network to connect to in response to a request from a specific app, the device stores the approval for the particular access point. If the app makes a specific request to connect to that access point again, the device skips the user approval phase and automatically connects to the network. If the user chooses to forget the network while connected to a network requested by the API, then this stored approval for that combination of app and network is removed, and any future request from the app must be approved by the user again.

Note: to be able to test this block, you have to build the app, because the permission WRITE_SETTINGS is not available in the companion app.


Disconnect. Available for Android >= 10.
Note: after disconnecting the device might reconnect automatically to the next available known network.
Thank you Wei Zheng for being the sponsor of this method.


Check, whether we have system write permission or not. Returns true or false. In case of false, the Android write settings menu of the app will be opened automatically.

Network Suggestion API

Sponsor of the network suggestion API methods is Santipong. Thank you Santipong!

Please note the following:

  1. If you disconnect the network from Wifi Settings (i.e press disconnect bin icon in the following image) your network will be blocked for 24 hours from auto-connect even if you removed the suggested network using RemoveNetworkSuggestions and add it again. And even if you uninstall and install your app again.

    Unfortunately, this is a limitation added by the Android System as described here: If the user uses the Wi-Fi picker to explicitly disconnect from one of the network suggestions when connected to it, then that network is blacklisted for 24 hours. During the blacklist period, that network will not be considered for auto-connection, even if the app removes and re-adds the network suggestion corresponding to the network.
  2. If you uninstall the application while connected to suggested WiFi, the system will close the connection automatically.
  3. In case you pressed "No" in notification prompt, you can change it from (Settings > Apps & notifications > Special App access > Wi-Fi Control > App name) as described here A user declining the network suggestion notification removes the CHANGE_WIFI_STATE permission from the app. The user can grant this approval later by going into the Wi-Fi control menu (Settings > Apps & notifications > Special App access > Wi-Fi Control > App name).


Add Network Suggestion. Available starting from Android 10/API level 29.


Remove Network Suggestion. Available starting from Android 10/API level 29.


Get all network suggestions of the calling app.

Events


Event indicating that Available SSIDs (Service Set Identifiers) have been scanned.
A list of the available SSIDs is provided in parameter availableSSIDs. The SSID having the best signal is provided in parameter bestSSID. A list of the corresponding RSSIs is provided in parameter correspondingRSSI. A list of corresponding BSSIs is provided in parameter correspondingBSSIs.
Thank you Tal for being the sponsor of the correspondingRSSI and correspondingBSSI functionality.


Event indicating that network is available. Available starting from Android 10.


Event indicating that error occurred.

Example App: WiFi Test






Screenshots

Test

Version 17 tested successfully on Samsung Galaxy A54 running Android 14.

Questions and Answers

Q1: I used Taifun Wifi Extension to search & connect to Available wifi network. But my problem rise when I connect using SSID & PASSWORD, the connection never succeeds. But if I set My access point to open network & I remove password from connect extension, the connection establish but only for few seconds & my phone connecting to another configured wifi network. My phone use android 8 api 26.
A: Problem solved. The SSID NAME in my case it must be between 6 to 11 character, the SSID NAME must be start with Character (do not use number for first character), the Password must at least 9 character . Now connection are made successfully. Thank you pjack2021.

Q2: After successfully connecting, when I go to the Android wifi settings. I click on my wifi (to see the information) and there is nothing. IP address, subnet mask, etc. but the connection to the wifi network is successful.
A: Yes, this is the correct behavior for devices starting from Android 10. See also the explanation from Google here: Network request API: targets apps that need to connect to a peer device, such as when configuring an IoT device or transferring files to a camera. In such cases, the peer device starts up a SoftAP and the API allows the app to guide the user to connect to the device. The resulting network is not intended to provide internet access, can't be used by the system, and can't be used by any app except the configuring app. User selection and approval is required the first time a connection is made to a new peer. Intended for IoT configuration apps and IoT file transfer apps.

.

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Test the functionality of the Wifi extension

The test app is available in Google Play. You can test the example following these steps

  1. Follow the opt-in URL to get access to the app and to be able to download it to your device. It might take a few hours for Google to enable you as beta tester!
  2. Start testing.

Buy the Wifi extension for App Inventor


You can buy this extension (aix file).
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 12 USD via Paypal
to Pura Vida Apps

2. Bitcoin

After having received your payment I will be happy to send the download link to you. Please let me know your Google account! I usually will send the download link not later than 24 hours after having received your payment.
Thank you! Taifun


Terms and Conditions

Latest free version of the WiFi extension (without Network Request API and Network Suggestion API methods)

I still provide the latest free version 15 of the extension here without support. There might be permission issues for some methods. Also the Connect method will not work anymore for newer devices. It is recommended to use the paid version instead.
Download TaifunWiFi extension (aix file) Version 15
Download Wifi example project (aia file)

Back to top of page ...


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact