请记住,这是针对android 11的。使用本机桥接的react本机应用程序。
例子:https://developer.android.com/guide/topics/connectivity/wifi-save-network-passpoint-config
在上面的示例中,我传递了passpoint配置,并将其添加到设备保存的网络列表中。
我怎么能现在;
检查创建的配置是否存在
删除创建的配置
我为什么问?
它不是wifisuggestions api的一部分,因此不能使用removesuggestion()
无法使用wifimanager.removenetwork(),因为它在api 29(android 10)中已被弃用
无法使用wifimanager.removepasspointconfiguration,因为api 29中也不推荐使用该配置。
我希望能够添加一个passpoint配置,检查它是否存在并删除它。
添加配置:
--- Passpoint Configuration created above this code ---
final WifiNetworkSuggestion suggestion1 = new WifiNetworkSuggestion.Builder()
.setPasspointConfig(passpointConfiguration)
.build();
final List<WifiNetworkSuggestion> suggestionsList = new ArrayList<WifiNetworkSuggestion>();
suggestionsList.add(suggestion1);
final WifiManager wifiManager1 = (WifiManager) reactContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
final int status = wifiManager1.addNetworkSuggestions(suggestionsList);
if (status != WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS) {
// Error handling
successCallback.invoke(false);
System.out.println("FAIL");
}
else {
System.out.println("SUCCESS");
successCallback.invoke(true);
}
活动结果:
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if (requestCode == 1000) {
if (resultCode == Activity.RESULT_OK) {
System.out.println("RESULT OK");
// network succesfully added - User pressed Save
} else if (resultCode == Activity.RESULT_CANCELED) {
System.out.println("RESULT CANCELLED");
// failed attempt of adding network to system - User pressed Cancel
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!