mandelbug
mandelbug

Reputation: 1798

Android Start VPNClient (com.ipsec.vpnclient) Programmatically

I have an android application that requires VPN. My users will be using Galaxy Note 3's and will be using the built in "VPN Client" (com.ipsec.vpnclient). I need to find a way to launch this application from my application, in the instance of the VPN dropping. I've already figured out a way to determine if the VPN dropped, but I still need a way to launch the application.

ANSWER:
Thanks to help from @Muthu I was able to get it working with the following method.

final Intent intent = new Intent("android.intent.action.VIEW");
intent.setComponent(new ComponentName("com.ipsec.vpnclient", "com.ipsec.vpnclient.MainActivity"));

EDIT:
To add to the confusion, I am easily able to add a shortcut to the activity (com.ipsec.vpnclient.MainActivity) via another Launcher like ADW or Nova. I also tried using com.ipsec.vpnclient.MainActivity instead of com.ipsec.vpnclient in the method below, to no avail.

Intent intent = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

The above method works with other packages, but I can't seem to get this one to launch.

Here is the application when viewed in Android System Info. enter image description here

Any ideas on how to launch this application programmatically?

Upvotes: 1

Views: 2124

Answers (1)

Muthu
Muthu

Reputation: 1022

You can Start any installed application by using intent. in your case like this

Intent LaunchVPN = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
startActivity( LaunchVPN );

Edit You can open pre installed apps that can be found inside settings page by

final Intent i = new Intent("android.intent.action.VIEW");
i.setComponent(new   ComponentName("com.android.settings","com.android.settings.InstalledAppDetails"));
startActivity(i);

Upvotes: 1

Related Questions