开发者

How to check if background data is enabled on the android?

开发者 https://www.devze.com 2023-02-01 00:51 出处:网络
I want to check if the user enabled background data on his/her device and display a message if it is disabled.

I want to check if the user enabled background data on his/her device and display a message if it is disabled.

How can I check if it has been enabled? I tried

import android.provider.Settin开发者_运维技巧gs;

//...
Settings.System.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);
//and
Settings.Secure.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);

But they are returning null.

Thank you, Achie.


You want to use the Connectivity Manager to get this info.

ConnectivityManager mgr = (ConnectivityManager)Context.getSystemService(Context.CONNECTIVITY_SERVICE);
boolean bgData = mgr.getBackgroundDataSetting();
0

精彩评论

暂无评论...
验证码 换一张
取 消