Android的API调用来确定用户设置和QUOT;数据启用" [英] Android API call to determine user setting "Data Enabled"

查看:171
本文介绍了Android的API调用来确定用户设置和QUOT;数据启用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序会检测移动网络是否可用在一定的位置。

My program tries to detect whether a mobile network is available at a certain location.

问题是,当我没有数据连接,这并不意味着该网络不存在......这取决于用户的preferences。
有可用于NetworkInfo.isAvailable(),以及用于用户设置API,例如用户是否正在漫游和漫游启用或飞行模式是否是

The issue is that when I don't have a data connection it doesn't mean the network is not there... it depends on the user preferences. There are APIs available for NetworkInfo.isAvailable(), and for user settings such as whether user is roaming and roaming is enabled or whether AirplaneMode is on.

我的问题是,我无法弄清楚用户是否有设置下禁用数据服务/ WirelessNetworks / MobileNetworks。

My problem is that I can't figure out whether the user has data services disabled under Settings/WirelessNetworks/MobileNetworks.

听起来像是一个微不足道的问题,但我还没有找到一个API调用。

Sounds like a trivial problem but I haven't found an API call.

感谢。

推荐答案

在您的活动:

boolean mobileDataAllowed = Settings.Secure.getInt(getContentResolver(), "mobile_data", 1) == 1;

来源:<一个href=\"http://$c$c.google.com/p/quick-settings/source/browse/trunk/quick-settings/src/com/bwx/bequick/handlers/MobileDataSettingHandler2.java\" rel=\"nofollow\">http://$c$c.google.com/p/quick-settings/source/browse/trunk/quick-settings/src/com/bwx/bequick/handlers/MobileDataSettingHandler2.java

这篇关于Android的API调用来确定用户设置和QUOT;数据启用&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆