Skip to content
Advertisement

Ifconfig and route command on Android

I wondering whether exist way to get result of ifconfig and route commands result programmatically in Android device? Can I do this in non rooted device?

Advertisement

Answer

In your AndroidManifest.xml file

JavaScript

Your code:

JavaScript

Output enter image description here

You can’t reach to know whether you are connected via wifi or network using WifiManager as WifiManager only deals with wifi. You have to use ConnectivityManager. I updated the code again where I merged WifiManager and ConnectivityManager to produce the result that you wanted.

Advertisement