Android : connect two devices by bluetooth and enable internet access programmatically

Viewed 169

I'm trying to connect two Android devices (already paired) by Bluetooth and enable automatically access to Internet in one of them.

This is possible by accessing in settings and enabling the below check case :

enter image description here

Do you have any idea how can i do this programmatically ?

Thanks.

1 Answers

This should be possible using WifiManager's setWifiApEnabled() method.

However, this method is only available up to Android SDK 27. It is marked as a SystemAPI and requires android.Manifest.permission.TETHER_PRIVILEGED.

It is therefore strongly unrecommended to implement this functionality for the reason that Google doesn’t provide any official API call for enabling the mobile hotspot.

You can read more about this topic here:

https://medium.com/@jean.creuzedeschatelliers/how-to-activate-the-mobile-hotspot-on-android-programmatically-or-not-5931e44097e3

Related