title: How to add additional handlings to Vpn disconnection in Android?
body: <p>I have a custom implementation of VpnService, which needs to perform some additional cleanup on disconnection. Everything works fine when I am stoping VpnService from my application using service bindings, but I need to perform that cleanup when client is disconnecting from the Vpn using system dialog.</p>
  
  <p>So, how can I catch the disconnection and add some handlings to that? </p>
  
  <p><a href="https://stackoverflow.com/questions/3461967/get-vpn-connection-status-on-android">Get VPN Connection status on Android</a> - this could be the solution, but it's not working on android 4+.</p>
  
  <p>From logs point of view there are only two entries:<br></p>
  
  <p><code>03-20 03:27:09.478: INFO/Vpn(504): Switched from org.my.package to [Legacy VPN]</code>
  <code>03-20 03:27:09.478: DEBUG/Vpn(504): setting state=IDLE, reason=prepare</code></p>