简体   繁体   中英

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

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:

在此处输入图像描述

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

Thanks.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM