My app connect directly to a hardware device that act as an access point (with no access to internet).
I can\'t connect because Android 5.0 automat
You can try to use new Lollipop API ConnectivityManager.requestNetwork(), supposedly like this:
ConnectivityManager cm = (ConnectivityManager) Context.getSystemService(Context.CONNECTIVITY_SERVICE);
cm.requestNetwork(new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.setNetworkSpecifier("XX:XX:XX:XX:XX:XX")
.build(),
new ConnectivityManager.NetworkCallback() {
void onAvailable(Network network) {
}
});
where XX:XX:XX:XX:XX:XX is your WiFi SSID. I'm not sure about it's format, and if it's used at all, I did not find any references to setNetworkSpecifier inside Android sources, except for the NetworkCapabilities class.