title: How to detect that a firewall has blocked Internet access to some app?
body: <p>This app must not work without active Internet connection. But, checking Internet connection via <code>ConnectivityManager</code> and <code>NetworkInfo</code> does not work if firewall apps like <code>DroidWall</code> have denied access to Internet (firewall rule). </p>
  
  <p>How can I detect that some firewall app has blocked Internet access to my app? </p>
  
  <p>For example, if I start Google Play Store app, it clearly states "No Internet connection". If I start my app, it hangs (trying to download content) and then crashes with an error. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is error caught by Logcat. </p>
  
  <pre><code>12-05 12:44:51.417: E/AndroidRuntime(18922): java.lang.RuntimeException: An error occured while executing doInBackground()
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at android.os.AsyncTask$3.done(AsyncTask.java:278)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.lang.Thread.run(Thread.java:856)
  12-05 12:44:51.417: E/AndroidRuntime(18922): Caused by: java.lang.NullPointerException
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at com.app.android.MainActivity$ParserAsyncTask.doInBackground(MainActivity.java:345)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at com.app.android.MainActivity$ParserAsyncTask.doInBackground(MainActivity.java:367)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  12-05 12:44:51.417: E/AndroidRuntime(18922):    ... 5 more
  </code></pre>
  
  <p>As you see, the mechanism which detects whether Internet connection (wifi or mobile data) exists or not failed as the app was started and the parser started downloading remote content. </p>
  
  <p>I need to implement additional feature which will allow Internet connection mechanism to check if some app is blocked by some firewall rule (like Play Store app does). </p>