title: WebView reload after connection recovered?
body: <p>[SOLVED] [FIXED CODE BELOW]</p>
  
  <p>It is a small app with a webview, i want to reload this when connection to internet is back. I open the app (with internet connected) and it shows the web (google.com.ar), when I disconnect WiFi and 3G if I navigate on the web it show error message, it is ok, but if I reconnect WiFi the app crashes. What is the problem? I think is in the BroadReceiver, in the manifest i have android.net.wifi.STATE_CHANGE and android.net.conn.CONNECTIVITY_CHANGE.</p>
  
  <p>Thanks.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.example.app;
  
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.os.StrictMode;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class MainActivity extends ActionBarActivity {
  
      static WebView myWebView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          StrictMode.enableDefaults();
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
  
          myWebView = (WebView) findViewById(R.id.webView);
          myWebView.loadUrl("http://google.com.ar");
  
          myWebView.setWebViewClient(new WebViewClient() );
  
      }
  
  }
  </code></pre>
  
  <p>ConnectionBroadReceiver.java</p>
  
  <pre><code>package com.example.app;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  
  public class ConnectionBroadReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          ConnectivityManager cm = (ConnectivityManager)    
          context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
          NetworkInfo netInfo = cm.getActiveNetworkInfo();
  
          if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
              MainActivity.myWebView.reload();
          } else {
          }
  
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.app"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="19"
          android:targetSdkVersion="19" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme"
          android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"&gt;
          &lt;activity
              android:name="com.example.app.MainActivity"
              android:label="@string/app_name"
              android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;receiver
              android:name="com.example.app.ConnectionBroadReceiver"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>