我正在尝试检查用户是否已启用/禁用数据漫游.到目前为止我发现的只是你可以使用TelephonyManager.isNetworkRoaming()和NetworkInfo.isRoaming()检查用户当前是否正在漫游,但它们不是我需要的.
小智 7
根据Nippey的回答,对我有用的实际代码是:
public Boolean isDataRoamingEnabled(Context context) {
try {
// return true or false if data roaming is enabled or not
return Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.DATA_ROAMING) == 1;
}
catch (SettingNotFoundException e) {
// return null if no such settings exist (device with no radio data ?)
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
您可以通过以下方式请求漫游交换机的状态
ContentResolver cr = ContentResolver(getCurrentContext());
Settings.Secure.getInt(cr, Settings.Secure.DATA_ROAMING);
Run Code Online (Sandbox Code Playgroud)
请参阅:http ://developer.android.com/reference/android/provider/Settings.Secure.html#DATA_ROAMING
| 归档时间: |
|
| 查看次数: |
7121 次 |
| 最近记录: |