Android Wifi Direct: Avoiding user acceptance when connecting to a known peer-ThrowExceptions

Exception or error:

While connecting to a peer using WiFi Direct, user’s permission is required. I know that connection can’t be made without user never giving the permission and there’s a feature request for this kind of functionality:

But I don’t need this feature, asking for permission on the first connection is OK (also, more secure). Is there any method such that the permission is asked for the first time only? And when trying to connect to same peer later, the permission is not required.

How to solve:

From the P2P specification we can find something called “persistent P2P group” which is intended to re-establish a group without user-intervention.

In a persitent P2P group the Group Owner stores the credentials of the group so that the group can be re-established in the future by the request of any group member without the need of user intervention.

Such a group can be formed by specifying persistent while connecting using command line (see the P2P of wpa_supplicant and search for p2p_connect command But I don’t know if the option is available with the current devices.

See the answer to the question Can I change the group owner in a persistent group in Wi-Fi Direct?

Since I worked with Wi-Fi Direct on Ubuntu, I used wpa_cli (which comes along with wpa_supplicant) to create a persistent group as specified in the p2p_readme file.


The closest thing to have Wi-Fi Direct features without prompt I’ve managed is to use Service Discovery combined with legacy mode, i.e. when the connection is supposed to happen, you don’t use WifiP2pManager.connect() but WifiManager.enableNetwork() instead.

I’m the author of a very simple P2P stack which automates all the magic, you can check out an example on to see how well/bad it works (plus some documentation).


Unfortunately, not at this time. Perhaps in the future, or if you write your own ROM.


I am using two HTC One V’s as well as an HTC One X+. I’ve been running the WifiDirectDemo given by Android. Apart from switching Wifi Direct on, no other setup is required. I simply press a search button in the application and peers are listed.

I did at first think I needed another devices permission as you’ve described, needing to reenable it every time I installed the application on my devices. But this was before I noticed the search button in the application, and realised this was not required.

Could you have made the same mistake as me?


Its possible through the reflection method.

Leave a Reply

Your email address will not be published. Required fields are marked *