如何强制使用 GPRS 连接而不是 3G 或 Wifi?

发布于 2024-11-30 02:48:22 字数 326 浏览 0 评论 0原文

我正在编写一个应用程序,即使有 wifi 或 3G(或更好的)可用,我也需要专门有 GPRS 连接。我已经弄清楚如何禁用 wifi(通过使用 WifiManager),但是,我似乎无法找出如何以编程方式禁用 3G 并仅使用 GPRS 连接,与更改此连接具有相同的效果在设备设置中手动设置。

有没有办法用代码来做到这一点?

更新:我正在寻找的内容不一定必须在公共 Android API 中。它也可能位于未记录的 API 中,或者作为最后的手段,特定于设备的 API,我只需要一些可以工作的东西。但是,我宁愿不必 root 设备即可使用这些功能。

I am writing an application where I need to have specifically a GPRS connection, even if wifi or 3G (or better) is available. I have figured out how to disable wifi (by using WifiManager), however, I can't seem to find out how I can programmatically disable 3G and only use a GPRS connection, with equal effect as changing this manually in the device settings.

Is there a way to do this with code?

UPDATE: What I am looking for does not necessarily have to be in the public Android APIs. It might as well be in one of the undocumented APIs, or as a last resort, device-specific APIs, I just need something that works. However, I'd rather not have to root a device to use these functions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅唱々樱花落 2024-12-07 02:48:22

问题不仅在于私有 API,还在于第 3 方 APK 无法获得修改此类设置的权限。

因此,除了对私有接口进行逆向工程之外,还需要有 root 权限的设备。

The issue is not just private APIs but that a 3rd party APK cannot get permission to modify such a setting.

As a result, doing so would require a rooted device in addition to reverse engineering private interfaces.

远山浅 2024-12-07 02:48:22

据我所知,不可能从应用程序中更改移动网络的类型。

as far as i know changing the type of the mobile network is not possible out from an app.

寄与心 2024-12-07 02:48:22

在android框架中,TelephonyManager是为android应用程序提供电话服务的对象。
请参阅http://developer.android.com/reference/android/telephony/TelephonyManager。 html
该服务确实提供了多种方法来了解物理无线电组件的状态和信息。

但是无法修改设备的物理无线电组件的工作方式。这是您的设备制造商的私有逻辑,试图尽最大努力遵守无线电通信工业标准并提供最佳的最终用户体验质量

这是公共 api android 观点(通过 dalvik)回答,不要在私有 android api 的上下文中回答,也不要以本机方式或 root 特权方式回答。

In android framework, TelephonyManager is the object providing Telephony service to android application.
see http://developer.android.com/reference/android/telephony/TelephonyManager.html
The service do provide several methods to know state and information of your physical radio component.

But there is no way to modify the way the physical radio component of your device do its job. Its a private logic of your device manufacturer that try to do its best to comply radiophony industrial standard and provide the best end user experience quality

This is an public api android point of view (over dalvik) answer, do not answer in context of private android api, nor native way nor root privileged way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文