Android Code Snippet Start Local Hotspot

Status
Not open for further replies.

Erel

Administrator
Staff member
Licensed User
Starting from Android 8 there is a public API for starting a local hotspot.

Notes:
- The hotspot doesn't allow internet connection.
- The password and SSID are chosen randomly and cannot be changed.
- Debug it with USB debug mode as it will break B4A-Bridge connection.



Project is attached. Don't miss the two permissions added in the manifest editor.
 

Attachments

JohnC

Well-Known Member
Licensed User
Is the SSID and password chosen randomly every time this API is used (each session), or just the first time (and they stay the same between sessions).

If it changes each session, I'm curious how this ability is useful because any app using this API can not reliable connect to something else in a subsequent session if the SSID and password keeps changing. Can you provide a description of some application ideas that could use this API so I can better understand how this API can be useful?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Is the SSID and password chosen randomly every time this API is used (each session)
They change each time you start the hotspot. The SSID and password are managed by the OS.

Can you provide a description of some application ideas that could use this API so I can better understand how this API can be useful?
You want to connect two or more nearby devices that are not connected to the same network (maybe there is no network at all).

Create the local network. Use QR Generator to create a QR code with the SSID and password. Scan it from the other devices and connect to the new network.
 

JohnC

Well-Known Member
Licensed User
Create the local network. Use QR Generator to create a QR code with the SSID and password. Scan it from the other devices and connect to the new network.
Ah, that was the missing piece - I was wondering how can this be useful if two devices didn't know what the connection info was of the other device.

...And I see there is a B4A library for both generating and reading QR codes - nice!
 

avalle

Active Member
Licensed User
Starting from Android 8 there is a public API for starting a local hotspot.
I'd say there's no way without Android 8 then... However I think that only the host device must have it. The "client" device can be anything.
 

welu1805

Active Member
Licensed User
I tried to install this example in Android 5, 6, and 7 with B4A-Bridge and get a "Parse error: There was a problem while parsing the package". But my app should work in older Android versions AND in Version 8. In older versions I create the Hotspot with setWifiApState and in v 8 with this erxample. What is wrong?
 
Status
Not open for further replies.
Top