title: Check for Internet connection, Android Studio on API 30
body: <p>I was using below method for checking weather user is connected to internet or not.</p>
  <pre><code> public boolean internetIsConnected() {
          try {
              String command = &quot;ping -c 1 google.com&quot;;
              return (Runtime.getRuntime().exec(command).waitFor() == 0);
          } catch (Exception e) {
  
              return false;
          }
      }
  </code></pre>
  <p>Manifest is as below</p>
  <pre><code>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt; 
  </code></pre>
  <p>but after I switched to latest API 30. It just freezes the app and returns false. any suggestion to get this working.</p>
  <p>Thank you.</p>
  <p>Edit :
  As per comment's suggestions I tried below similar method but still Not working.</p>
  <pre><code>public boolean internetIsConnected() {
          Runtime runtime = Runtime.getRuntime();
          try {
              Process ipProcess = runtime.exec(&quot;/system/bin/ping -c 1 8.8.8.8&quot;);
              int exitValue = ipProcess.waitFor();
              System.out.println(&quot; mExitValue &quot;+exitValue);
              return (exitValue == 0);
          } catch (IOException e){
              System.out.println(&quot; IO Error &quot;);
              e.printStackTrace(); }
          catch (InterruptedException e) {
              System.out.println(&quot; Interrupted Error &quot;);
              e.printStackTrace(); }
          return false;
      }
  </code></pre>
  <p>I got :</p>
  <pre><code>I/System.out:  mExitValue 1
  </code></pre>
  <p>So it is failing in Try block itself. I tried finding what Exit value &quot;1&quot; means but it only shows for &quot;0&quot; <a href="https://developer.android.com/reference/java/lang/Process#waitFor()" rel="nofollow noreferrer">Here</a> This Happens in both Emulator as well as physical device. Any suggestion is appreciated.</p>
  <p>Thank you</p>