使用自定义 APN 进行连接
我正在开发一个应用程序,需要连接到只能通过特殊 APN 访问的服务器。因此,我想知道,是否可以指定一个 APN 仅用于单个连接(或应用程序),并使用它,即使 wifi 处于活动状态?
I am developing an application where I need to make a connection to a server which is only accessible through a special APN. Therefore, I want to know, is it possible to specify an APN to use for a single connection (or application) only, and use that, possibly even if wifi is active?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您的应用程序可能需要 WRITE_APN_SETTINGS 权限能够更改 APN。您可以调出一个 UI 界面,让用户使用以下代码配置 APN:
另一方面,以编程方式更改设置有点困难。我建议您查看此类似问题的答案,以了解更多信息。
Firstly, your application will probably need the WRITE_APN_SETTINGS permission in order to be able to make APN changes. You can bring up a UI interface to have the user configure the APN with this code:
Changing the settings programatically, on the other hand, is a bit more difficult. I recommend you take a look at the answers to this similar question for more information.