title: How to avoid InvocationTargetException when invoke WifiP2pManager.setWFDInfo()?
body: <p>I am trying to create an android Wi-Fi Display (Miracast) application.</p>
  <p>I use following codes to register a sink port:</p>
  <pre><code>Class clsWifiP2pManager = Class.forName(&quot;android.net.wifi.p2p.WifiP2pManager&quot;);
  Method methodSetWFDInfo = clsWifiP2pManager.getMethod(&quot;setWFDInfo&quot;,
                              WifiP2pManager.Channel.class, clsWifiP2pWfdInfo, WifiP2pManager.ActionListener.class);
  methodSetWFDInfo.invoke(wifiP2pManager, channel, wifiP2pWfdInfo, listener);
  </code></pre>
  <p>but when the app is running, throws some exceptions:</p>
  <pre><code>W/System.err: java.lang.reflect.InvocationTargetException
  W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
  ...
  W/System.err: Caused by: java.lang.SecurityException: Wifi Display Permission denied for uid = 10055
  W/System.err:     at android.os.Parcel.createException(Parcel.java:1953)
  W/System.err:     at android.os.Parcel.readException(Parcel.java:1921)
  W/System.err:     at android.os.Parcel.readException(Parcel.java:1871)
  W/System.err:     at android.net.wifi.p2p.IWifiP2pManager$Stub$Proxy.checkConfigureWifiDisplayPermission(IWifiP2pManager.java:205)
  W/System.err:     at android.net.wifi.p2p.WifiP2pManager.setWFDInfo(WifiP2pManager.java:1391)
  W/System.err:   ... 21 more
  </code></pre>
  <p>i know that there have <code>checkConfigureWifiDisplayPermission()</code> in <strong>setWFDInfo()</strong>, it will check if my app have the system app permission: <code>android.permission.CONFIGURE_WIFI_DISPLAY</code> , but this app is not a system app, so how could i avoid the permission checking or avoid the exception: <code>InvocationTargetException</code> ?</p>
  <p>by the way, i have already add this permission in my <code>AndroidManifest.xml</code>:</p>
  <pre><code>    &lt;uses-feature android:name=&quot;android.hardware.wifi&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&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;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_MEDIA_LOCATION&quot;/&gt;
  </code></pre>