public static boolean executeCommand(){
System.out.println("executeCommand");
Runtime runtime;
runtime = Runtime.getRuntime();
try
{
Process mIpAddrProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
int mExitValue = mIpAddrProcess.waitFor();
System.out.println(" mExitValue "+mExitValue);
if(mExitValue==0)
{
return true;
}
else
{
return false;
}
}
catch (InterruptedException ignore)
{
ignore.printStackTrace();
System.out.println
(" Exception:"+ignore);
}
catch (IOException ex)
{
ex.printStackTrace();
System.out.println(" Exception:"+ex);
}
return false;}
Tuesday, 29 September 2015
How to Ping External IP from Java Android
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment