8

I have been looking around for a way to launch the VPN settings activity through my android app, but cannot find it. Note that I am targeting Android 2.2, hence will not be able to use the facilities provided in android ICS.

What is the action that I should pass into an Intent in order to get the VPN settings screen to open up ?

Heshan Perera
  • 4,592
  • 8
  • 44
  • 57

2 Answers2

12

I think this is what you are looking for:

Intent intent = new Intent("android.net.vpn.SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
aplik
  • 121
  • 1
  • 3
  • 1
    This works on Kit Kat, thanks. The VpnManager class shown in the accepted answer appears to have been removed in newer Android OS versions. – mbonness Mar 11 '15 at 16:52
  • Thanks, android 5.1 is OK, its save my a lot of time everyday ^_- – Ninja Jan 08 '16 at 09:04
  • Thanks, this worked with "llama" to allow me to send "Start Activity" - the uppercase is what I had been missing. – Aaron D. Marasco Sep 29 '16 at 14:38
2

try this:

    private static final String PACKAGE_PREFIX =
            VpnManager.class.getPackage().getName() + ".";
    private static final String ACTION_VPN_SETTINGS =
            PACKAGE_PREFIX + "SETTINGS";
    Intent intent = new Intent(ACTION_VPN_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(intent);
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213