问题
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 ?
回答1:
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);
回答2:
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);
来源:https://stackoverflow.com/questions/10731306/android-action-to-open-up-vpn-settings-activity