I have added a passpoint configuration in my app on Android 11. The add works perfectly but it doesn't connect.
I tried to get a list of which passpoints are added but get an empty list.
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)
I get the popup asking me to confirm the adding and I click okay.
In the Activity I have the following:
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() returns an empty list as does getPasspointConfigurations() and yet, the profile DOES appear in the list of saved networks.
Am i missing something here?
From your code I can see that you have not added passpoint configuration to your suggestion list.
You can read more about passpoint configuration in Blog about passpoint configuration in Android
Then add this list to your bundle.