Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <uses-permission android:name="android.permission.INTERNET" />
- Runtime runtime = Runtime.getRuntime();
- try {
- Process mIpAddrProcess = runtime.exec("/system/bin/ping -w 2 8.8.8.8");
- mExitValue = mIpAddrProcess.waitFor();
- BufferedReader reader = new BufferedReader(new InputStreamReader(mIpAddrProcess.getInputStream()));
- int i;
- char[] buffer = new char[4096];
- StringBuffer output = new StringBuffer();
- while ((i = reader.read(buffer)) > 0)
- output.append(buffer, 0, i);
- reader.close();
- String str = output.toString();
- if (mExitValue == 0)
- {
- Toast.makeText(getApplicationContext(),"Connection ok"+ str, Toast.LENGTH_SHORT).show();
- } else
- {
- Toast.makeText(getApplicationContext(), "Please Check Your Internet Connection"+str, Toast.LENGTH_SHORT).show();
- //new Description().execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement