How use "android.net.wifi.NetworkSpecifier.Builder" with jnius?

213 Views Asked by At

The issue is: I was using "android.net.wifi.WifiConfiguration" for connecting to WIFI like this: Correctly Working.

from jnius import  autoclass

ssid = str("ssid_name")
print("app says-->connecting to wifi:",ssid)
String = autoclass('java.lang.String')
WifiConfigure = autoclass('android.net.wifi.WifiConfiguration')
PythonActivity = autoclass('org.kivy.android.PythonActivity')
activity = PythonActivity.mActivity
service = activity.getSystemService("wifi")               
WifiManager = autoclass('android.net.wifi.WifiManager')
WifiConfig = WifiConfigure()
>                                         #       #       #       #
Connectname = String(ssid)
connectkey = String("Wifi Password")
WifiConfig.SSID = "\""+Connectname.toString()+"\""
WifiConfig.hiddenSSID = True
WifiConfig.preSharedKey ="\""+ connectkey.toString()+"\""
added = WifiManager.addNetwork(WifiConfig)
WifiManager.enableNetwork(added, True)`

But after API 29 that java library is deprecated, and I need to deploy on Play Store the Android App Bundle with at least API 30.

So: On site https://developer.android.com they speaking about use "android.net.wifi.NetworkSpecifier.Builder" instead of "android.net.wifi.WifiConfiguration", is there anyone to tell me how to use integrate with jnius and autoclass?

I expect python programmers to help me solve the problem

1

There are 1 best solutions below

0
On

You cannot programmatically connect to Wi-Fi after API 30.