Check internet connectivity when click a button
<p>i want to figure out when a button click , it will check for internet connectivity, if is connected, then will intent to another page. If not, it will toast a message.</p>

<p>Somehow, i got saw a lot of example post in this forum but no one is same like mine. Can anyone advice?</p>

<pre><code>search.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {


                Intent gogogo = new Intent(webview.this, viewPage.class);
                gogogo.putExtra("result", result);
                startActivity(gogogo);
            }
        });

final ConnectivityManager conn_manager = (ConnectivityManager) 
            this.getSystemService(Context.CONNECTIVITY_SERVICE);


            final NetworkInfo network_info = conn_manager.getActiveNetworkInfo();
            if ( network_info != null &amp;&amp; network_info.isConnected() ) 
            {
                return true;
            }
            else
            {
                return false;
            }
</code></pre>

<p>I figure out many post is like coding above but can't have any idea to put on my code above.</p>
