title: Howto connect to a VPN, which is already setup in an Android phone, programmatically
body: <p>I have configured a VPN connection in my Android phone. Now I would like to connect this VPN via a widget. How can I initiate a connection programmatically? Most code assumes there is no VPN setup yet, but this is not where I am looking for. I look especially for code which connects to an already configured VPN.</p>
  
  <p>On <a href="http://code.google.com/p/android/issues/detail?id=8915" rel="noreferrer">http://code.google.com/p/android/issues/detail?id=8915</a> I have found this code:</p>
  
  <pre><code>VpnService service = context.getSystemService(VPN_SERVICE);
  VpnProfile profile = VpnProfile.create(L2TP_PROFILE);
  profile.setName(myServerName);
  profile.setServerName(myServerAddress);
  profile.setRouteList(“192.168.1.0/255.255.255.0,192.168.10.0/255.255.255.0”);
  
  service.connect(profile, myUserName, myPassword);
  service.setNotificationIntent(myIntent);
  </code></pre>
  
  <p>Which configures a new VPN. I want just to connect an existing VPN.</p>
  
  <p>This page <a href="http://developer.android.com/reference/android/net/VpnService.html" rel="noreferrer">http://developer.android.com/reference/android/net/VpnService.html</a> describes how to implement your own VPN service, which is also not what I am looking for.</p>