我正在尝试编写一个可以使用pptp protocol
连接到我的VPN服务器的应用程序,因为我正在研究我发现android.net.vpnservice
我可以连接,但是当我阅读一些文档时目前尚不清楚如何连接 VPN (没有API来设置用户名或密码,也没有API来设置我的VPN类型(l2tp,pptp
);我还测试了示例应用程序Google提供(toyvpn)并且我之前也没有提到过。
以下是我发现的一些代码:
// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mServerAddress)
.setConfigureIntent(mConfigureIntent)
.establish();
mParameters = parameters;
答案 0 :(得分:5)
嗨,这有点晚了,但我在搜索时发现了一些东西。
我也在尝试使用pptp和openvpn构建自己的VPN隧道/连接。
OpenVPN已经有了解决方案。
PPTP正在尝试以下解决方案。
How to programmatically create a new VPN interface with Android 4.0?
上面的链接是在
找到的答案 1 :(得分:3)
我也在尝试。
对于VPN服务,您可以这样做。
void startVPN(String name) {
Intent i=new Intent("doenter.onevpn.ACTION_CONNECT");
i.putExtra("name",name);
i.putExtra("force", true);
i.putExtra("force_same", false);
startActivity(i);
}
void restartVPN(String name) {
Intent i=new Intent("doenter.onevpn.ACTION_CONNECT");
i.putExtra("name",name);
i.putExtra("force", true);
i.putExtra("force_same", true);
startActivity(i);
}
void stopVPN() {
Intent i=new Intent("doenter.onevpn.ACTION_DISCONNECT");
// Stops any VPN regardless of name
startActivity(i);
}
此链接可以帮助您获得答案。
http://doandroids.com/Apps/OneVpn/how-to/start-stop-prgrammatically/