How to check internet availability in android on coming back to the application from phone menu
<p>In my UI i check the network availability in a button click listner</p>

<pre><code>NewButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if(isInternetAvailable)
                {
                Intent intent = new Intent(FeaturedListActivity.this,
                        NewJewelsActivity.class);
                startActivity(intent);
                finish();
                }
                else
                {
                    MyAlertDialog.ShowAlertDialog(FeaturedListActivity.this, "", "Check Network Connection.", "OK");    
                }
            }
        });
</code></pre>

<p>I check network availability using the following code</p>

<pre><code>public boolean isNetworkAvailable() {
          ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(getApplicationContext().CONNECTIVITY_SERVICE);
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            return activeNetworkInfo != null;
</code></pre>

<p>Now my problem is when i start the app with the wifi  in off state the condition will work and will show the "check network connection" dialog. And now i press the center button of the phone and turn on the wifi and coming back to the screen from where i left.Now the wifi is in ON state and it still shows "check network connection".If i restart the app it will not show the dialog.How can i solve this?</p>

<pre><code>}
</code></pre>
