将所有互联网流量从我的 android voip 应用路由到我自己的 vpn 服务器

Route all the internet traffic from my android voip app to my own vpn server

我们已经设置了自己的 VPN 服务器,并希望通过此服务器路由来自我们的 VOIP android 应用程序的所有流量。

但到目前为止我看到的所有解决方案都使用 vpn 服务 class http://developer.android.com/reference/android/net/VpnService.html,它为整个设备创建了一个 vpn 隧道,而不仅仅是我的应用程序。我希望 phone 上的其他应用程序 运行 正常使用互联网,而我们应用程序的流量通过我们的 VPN 服务器路由。

有办法吗?我非常感谢任何建议。谢谢

VpnService不需要应用到整个设备。请参阅:VpnService.Builder.addAllowedApplication(适用于 API 21 - 5.0):

Adds an application that's allowed to access the VPN connection. If this method is called at least once, only applications added through this method (and no others) are allowed access. Else (if this method is never called), all applications are allowed by default. If some applications are added, other, un-added applications will use networking as if the VPN wasn't running.