小编use*_*428的帖子

在 Android 上以编程方式设置 vpn

我找到了以下代码以编程方式建立一个新的 vpn,但我不知道如何使用它来创建我的应用程序

VpnService service = context.getSystemService(VPN_SERVICE);
VpnProfile profile = VpnProfile.create(L2TP_PROFILE);
profile.setName(myServerName);
profile.setServerName(myServerAddress);
profile.setRouteList("192.168.1.0/255.255.255.0,192.168.10.0/255.255.255.0");
service.connect(profile, "myUserName", "myPassword");
service.setNotificationIntent(myIntent);
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我提供示例代码吗?甚至有可能实现dis吗?

vpn android android-vpn-service

6
推荐指数
1
解决办法
8766
查看次数

标签 统计

android ×1

android-vpn-service ×1

vpn ×1