我想检查用户是否在他/她的设备上启用了背景数据,并在禁用时显示消息.
如何检查是否已启用?我试过了
import android.provider.Settings;
//...
Settings.System.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);
//and
Settings.Secure.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);
Run Code Online (Sandbox Code Playgroud)
但他们正在返回null.
谢谢,成就.
Jes*_*ess 10
您想使用连接管理器来获取此信息.
ConnectivityManager mgr = (ConnectivityManager)Context.getSystemService(Context.CONNECTIVITY_SERVICE);
boolean bgData = mgr.getBackgroundDataSetting();Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3104 次 |
| 最近记录: |