title: What options are available for ensuring VPN connection is available on Android?
body: <p>My app performs actions on a remote host via VPN. Everything works great: On a fresh phone I create the VPN manually and ensure it works, load the app up and run it to perform the remote action and go on with my day. My app also notifies me of things happening remotely, so the connection must be kept active for this to work. For now the app detects when the remote host is unreachable and sends a notification to inform me of the loss of connectivity so I can click on the reconnect button in Android's VPN status screen. </p>
  
  <p>What I want is to programmatically "push" that button instead.</p>
  
  <p>I'm <em>not</em> looking to add a new VPN connection with code, not even to start it with code -- I only want the VPN to be reconnected upon disconnection. Why doesn't Android support auto-reconnect, even if it were to only try a few times before giving up completely like the current implementation does.</p>
  
  <p>The app will never be distributed, it's only for our in-house support staff, so I'm not concerned about backwards compatibility or device-specific problems as long as it works on the target device: Galaxy S III</p>
  
  <p>At the moment, the app provides a shortcut to the connection <code>intent</code> for the user to quickly access the VPN screen using the SETTINGS intent:</p>
  
  <pre><code>public void openVPN(View view) {   
      startActivity(new Intent("android.net.vpn.SETTINGS"));
  }
  </code></pre>
  
  <p>While this works for manually reconnecting, it's still annoying to have to do it and involves several taps to complete. I've searched everywhere and no one seems to have an elegant solution to this without rooting the phone and using a 3rd party VPN client package instead of the Android client. </p>
  
  <p>Am I out of luck using the stock API or is there some secret ninja API that would have what I need, even if it means losing backward and forward compatibility?</p>
  
  <p>This is my first question to Stack Overflow!</p>