Search code examples
androidandroid-vpn-service

Is there an 'on forget' vpn listener?


I'm developing an app that implements a VPN service and I want to listen when the user clicked "Forget VPN" on my app's VPN service from android settings.

Is there a way to do it?


Solution

  • When checking the source code of VpnSettings#deleteProfile() - there is nothing being broadcasted.

    The only available callback seems to be VpnService#onRevoke(); as the documentation states:

    Invoked when the application is revoked. At this moment, the VPN interface is already deactivated by the system. The application should close the file descriptor and shut down gracefully. The default implementation of this method is calling Service#stopSelf().