本文整理汇总了Java中android.net.ConnectivityManager.getBackgroundDataSetting方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectivityManager.getBackgroundDataSetting方法的具体用法?Java ConnectivityManager.getBackgroundDataSetting怎么用?Java ConnectivityManager.getBackgroundDataSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.ConnectivityManager
的用法示例。
在下文中一共展示了ConnectivityManager.getBackgroundDataSetting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleIntent
import android.net.ConnectivityManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void handleIntent() {
// obtain the wake lock
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Partial");
mWakeLock.acquire();
// check the global background data setting
ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
if (!cm.getBackgroundDataSetting()) {
stopSelf();
return;
}
// do the actual work, in a separate thread
new PollTask().execute();
}
示例2: checkInternet
import android.net.ConnectivityManager; //导入方法依赖的package包/类
public static boolean checkInternet(Context context){
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
// 检查网络连接,如果无网络可用,就不需要进行连网操作等
NetworkInfo info = manager.getActiveNetworkInfo();
if (info == null || !manager.getBackgroundDataSetting()) {
return false;
}
return true;
}
示例3: isBackgroundDataActivated
import android.net.ConnectivityManager; //导入方法依赖的package包/类
private boolean isBackgroundDataActivated() {
ConnectivityManager connManager = (ConnectivityManager) mActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
return connManager == null ? true : connManager.getBackgroundDataSetting();
}