Android ez 2013-06-21
利用 Ping 的方法檢查網路是否正常!
public boolean NetworkIsAccess(){
try
{
Runtime runtime = Runtime.getRuntime();
Process mIpAddrProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
int mExitValue = mIpAddrProcess.waitFor();
return mExitValue==0;
}
catch (Exception ex) { }
return false;
}標籤: Android
