Efe AYDIN
Efe AYDIN

Reputation: 203

Android WifiP2pManager DialogListener Class Not Found Exception

I am developing an app based on Android Wi-Fi Direct. I want to connect devices without foreground dialog permission. Codes in the link below work properly for Galaxy Note 4 (Android 6.0.1) but when I tried it on LG G3 (Android 5.0) it throws ClassNotFoundException at code below.

dialogInterface = Class.forName("android.net.wifi.p2p.WifiP2pManager$DialogListener");

https://github.com/octoblu/alljoyn/blob/master/alljoyn/alljoyn_java/helper/org/alljoyn/bus/p2p/WifiDirectAutoAccept.java

Upvotes: 0

Views: 317

Answers (1)

Josh Feldman
Josh Feldman

Reputation: 547

There might not be a whole lot you can do in this case.

DialogListener is marked as @hide in WifiP2pManager, and there is no guarantee that this interface will exist across all versions of Android. Based on the stock 6.0.1 source code, I don't even see evidence that this interface exists, so I'm surprised this even works on the Note (unless Samsung did some customization). I do see this interface in 4.1.2, though.

To troubleshoot issues with reflection, I recommend using a debugger to examine the object (WifiP2pManager) that is giving you trouble.

Upvotes: 1

Related Questions