Disconnect the VPN that other apps have enabled in Android

1000 Views Asked by At

Is there a way to disconnect any VPN connection on the Android device? My app uses Wi-Fi Direct to establish a P2P connection with other devices. On some devices, Wi-Fi Direct does not work when the VPN is active, and I want to disconnect any VPN connection that is enabled on the device. I tried this code and was able to do so. But using this, the user is asked for permission to access the VPN and then a VPN connection is created with the name of my app. So I do not want to use this code.

startActivityForResult(VpnService.prepare(this), 0);

If there is no way to disconnect, how can the user be redirected to the VPN settings page to do so manually?

0

There are 0 best solutions below