我在 Android 11 上的应用程序中添加了一个 passpoint 配置。添加工作完美,但无法连接。
我试图获取添加了哪些通行证的列表,但得到了一个空列表。
val config = PasspointConfiguration()
config.credential = Credential().apply {
userCredential = Credential.UserCredential().apply {
username = "******"
password = Base64.getEncoder().encodeToString("*****".toByteArray())
eapType = 21
nonEapInnerMethod = "MS-CHAP-V2"
}
realm = "merki.local"
certCredential = null
caCertificate = myCertificate
clientPrivateKey = null
clientCertificateChain = null
}
config.homeSp = HomeSp().apply {
fqdn = "meraki.com"
friendlyName = "Meraki"
}
val bundle1 = Bundle()
bundle1.putParcelableArrayList(EXTRA_WIFI_NETWORK_LIST, suggestionsList)
val intent = Intent(ACTION_WIFI_ADD_NETWORKS)
intent.putExtras(bundle1)
context.startActivityForResult(intent, 9999)
我收到弹出窗口,要求我确认添加,然后单击确定。
在活动中,我有以下内容:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
LOG.d("onActivityResult requestCode= ",requestCode, " resultCode= ", resultCode);
if (requestCode == 9999){
if(resultCode == RESULT_OK) {
// user agreed to save configurations: still need to check individual results
if (data != null && data.hasExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)) {
for(int code : data.getIntegerArrayListExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)) {
switch (code) {
case ADD_WIFI_RESULT_SUCCESS:
List<WifiNetworkSuggestion> passpoints = ((WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE)).getNetworkSuggestions();
break;
case ADD_WIFI_RESULT_ADD_OR_UPDATE_FAILED:
break;
case ADD_WIFI_RESULT_ALREADY_EXISTS:
break;
default:
break;
}
}
}
} else {
// User refused to save configurations
}
}
}
getNetworkSuggestions() 与 getPasspointConfigurations() 一样返回一个空列表,但配置文件确实出现在已保存网络的列表中。
我在这里错过了什么吗?