To check wifi or 3G exist in android
<p>Hello 
In my android application i am using the below code to make sure that network exists.</p>

<p>But am receiving error at the very first line.Do i need to check any permission other than those listed.</p>

<pre><code>public static boolean haveInternet(Context ctx) { 

NetworkInfo info = (NetworkInfo) ((ConnectivityManager) ctx 
        .getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); 

if (info == null || !info.isConnected()) { 
    return false; 
} 
if (info.isRoaming()) { 
    // here is the roaming option you can change it if you want to 
    // disable internet while roaming, just return false 
    return false; 
} 
return true; 
</code></pre>

<p>Permissions in manifest</p>

<pre><code>&lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;   
&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name= "android.permission.CHANGE_NETWORK_STATE"&gt;&lt;/uses-permission&gt;
</code></pre>
