android - OpenVPN Connect 应用程序是否有 Intent/接收者添加新的 VPN 配置文件?

标签 android android-intent vpn openvpn

我正在尝试找到一种解决方案来控制我构建的 Android 应用程序中的 vpn 连接。到目前为止我可以找到以下结果:

  • 自 Android 版本 2.3.x 起,无法通过 Intent 控制 Android 的 VPN 客户端。
  • VpnService 提供了从头开始构建您自己的 VPN 解决方案的方法,并且没有任何通用协议(protocol)。

我找到了一种解决方案,通过使用 Android 的“openvpn connect”应用程序并结合我从应用程序发送的 Intent ,以编程方式连接和断开 VPN 连接。是否有可能以编程方式(通过 Intent )添加新的 openvpn 配置文件?用户交互(例如接受或同意添加新配置文件)是可以的。

最佳答案

    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.setComponent(new ComponentName("net.openvpn.openvpn","net.openvpn.openvpn.OpenVPNAttachmentReceiver"));
    intent.setDataAndType(Uri.parse(file_path), "application/x-openvpn-profile");
    startActivity(intent);

关于android - OpenVPN Connect 应用程序是否有 Intent/接收者添加新的 VPN 配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24927631/

相关文章:

javascript - 在 Phonegap 和 WebIntent 中使用 Android 推送通知

javascript - S.browser_fallback_url 是什么时候在 Chrome 中引入的?

android - 当声音以线程结束时如何更改 imageView

android - 获取Android设备的硬件序列号

android - 如何将数组列表 <Object> 传递给另一个 Activity

amazon-ec2 - 能够通过 VPN 从本地 ping EC2。但是,无法 ping DMS 复制实例

azure - 使用新的 Azure 门户进行点到站点连接

azure - 访问虚拟机的成本

android - 如何通过 Appium 为 Android 设备获取/设置网络连接

android - 如何使用这种格式的 gradle 更改 apk 名称?