Android: Action to open up VPN Settings Activity

痞子三分冷 提交于 2019-12-19 03:38:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!