I need to get router ipv4 address
to my android phone. Is it possible to do that? It's easy to get ipv4 from computer I jus need to type ipconfig
to cmd
But how to get already connected router ipv4 from android device? Here's my android code where I connect to router
@Override
public void onReceive(Context context, Intent intent) {
List<ScanResult> list = scanner.getScanResults();
for(ScanResult result : list){
if(result.SSID.equals("Micro")){
//Connect to THIS network
connect(result.SSID);
break;
}
}
}
public void connect(String name){
String password = "logitech";
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + name + "\"";
conf.preSharedKey = "\""+ password +"\"";
scanner.addNetwork(conf);
List<WifiConfiguration> list = scanner.getConfiguredNetworks();
for( WifiConfiguration i : list ) {
if(i.SSID != null && i.SSID.equals("\"" + name + "\"")) {
int neiID = list.get(0).networkId;
Log.d(TAG, "" + neiID);
scanner.disconnect();
scanner.enableNetwork(i.networkId, true);
scanner.reconnect();
break;
}
}
}