title: Exception reading Wifi/3G State
body: <p>Hi I have the following code that reads Network/Wifi state:</p>
  
  <pre><code>public String getMacAddress() {
      WifiManager wm = (WifiManager) context
              .getSystemService(Context.WIFI_SERVICE);
      return wm.getConnectionInfo().getMacAddress();
  }
  </code></pre>
  
  <p>This throws</p>
  
  <pre><code>Caused by: java.lang.SecurityException: WifiService: Neither user 10032 nor current process has android.permission.ACCESS_WIFI_STATE
  </code></pre>
  
  <p>And</p>
  
  <pre><code>public boolean is3G() {
      ConnectivityManager connectivityManager = (ConnectivityManager) context
              .getSystemService(Context.CONNECTIVITY_SERVICE);
      return !(connectivityManager.getNetworkInfo(
              ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connectivityManager
              .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED);
  }
  </code></pre>
  
  <p>This throws</p>
  
  <pre><code>Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10032 nor current process has android.permission.ACCESS_NETWORK_STATE.
  </code></pre>
  
  <p>Before someone tell me about the permissions, that is my Manifest (the relevant part):</p>
  
  <pre><code>&lt;manifest&gt; 
     &lt;!-- usual tags for activitys... etc.. --&gt;
  
      &lt;uses-permission android:name="android.permission.WRITE_OWNER_DATA" /&gt;
      &lt;uses-permission android:name="android.permission.READ_OWNER_DATA" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;user-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;user-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;/manifest&gt; 
  </code></pre>