title: Unity3D how to add permissions to AndroidManifest.xml for android plugin
body: <p>So I'm working on a Unity plugin for android and I've found a problem that seems poorly documented. I need to add the INTERNET, CHANGE_WIFI_STATE, ACCESS_WIFI_STATE, CHANGE_NETWORK_STATE, and ACCESS_NETWORK_STATE permissions to my project.</p>
  <p>I added them to the AndroidManifest.xml file in my android plugin package, but I get an error saying that I need permissions. I believe that I need to add the permissions to a different AndroidManifest.xml in the Unity build. I'm not really sure how to get Unity to add them. (I was able to add the internet permission via player settings in build)</p>
  <p>Unity Manual says that the only way to do this is to edit the Manifest file manually, but that seems like a bad way to go about it; I wouldn't want everyone who uses the plugin to have to manually edit their file. Also, I have a custom third party asset imported into this project and looking at Unity's AndroidManifest file, I see that the asset was able to add its permissions to the manifest file without me having to do anything, so I know that what I want to do is possible.</p>
  <p>Also, I believe all of my permissions are not considered dangerous so I don't have to manually ask the user for permission, but if I did, I'm not sure how I would go about asking.</p>
  <p>Here is some of the code for my project that might be of use:</p>
  <p>The AndroidManifest.xml in my plugin package:</p>
  <pre><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.unitywifidirectlibrary&quot; &gt;
  
      &lt;uses-permission android:name=&quot;ANDROID.PERMISSION.INTERNET&quot;/&gt;
      &lt;uses-permission android:name=&quot;ANDROID.PERMISSION.ACCESS_NETWORK_STATE&quot;/&gt;
      &lt;uses-permission android:name=&quot;ANDROID.PERMISSION.CHANGE_NETWORK_STATE&quot;/&gt;
      &lt;uses-permission android:name=&quot;ANDROID.PERMISSION.ACCESS_WIFI_STATE&quot;/&gt;
      &lt;uses-permission android:name=&quot;ANDROID.PERMISSION.CHANGE_WIFI_STATE&quot;/&gt;
  
      
  &lt;/manifest&gt;
  </code></pre>
  <p>The error that I get when I attempt to check if WiFi is enabled as a test:</p>
  <p><code>java.lang.SecurityException WifiP2pService: Neither user 10194 nor current process has android.permission.ACCESS_WIFI_STATE.</code></p>
  <p>The function that causes the error:</p>
  <pre><code>public static string DisplayWifiStatus()
      {
          if (!isSetup)
              setup();
          string result = &quot;function was not called&quot;;
          if (Application.platform == RuntimePlatform.Android)
          {
              try
              {
                  result = WDAndroid.Call&lt;string&gt;(&quot;displayWifiStatus&quot;);
              }
              catch (Exception e)
              {
                  result = e.Message;
              }
          }
          else
          {
              print(&quot;(DisplayWifiStatus) This function is not supported on this platform&quot;);
          }
          return result;
      }
  
  </code></pre>
  <p>Does anyone have any experience with this problem? Any ideas for things I could try? Thanks!</p>