Android examples for Map:Location
is Location Enabled
//package com.java2s; import android.content.ContentResolver; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; public class Main { @SuppressWarnings("deprecation") public static boolean isLocationEnabled(ContentResolver contentResolver) { int locationMode = 0; String locationProviders; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { locationMode = Settings.Secure.getInt(contentResolver, Settings.Secure.LOCATION_MODE); } catch (Settings.SettingNotFoundException e) { e.printStackTrace();//from w w w. j a v a2 s .co m } return locationMode != Settings.Secure.LOCATION_MODE_OFF; } else { locationProviders = Settings.Secure.getString(contentResolver, Settings.Secure.LOCATION_PROVIDERS_ALLOWED); return !TextUtils.isEmpty(locationProviders); } } }