To check if Location Services are enabled:
/**
* Method to check if location enable
*/
public static boolean isLocationEnabled(Context p_context) {
int m_locationMode = 0;
String m_locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
m_locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (SettingNotFoundException m_e) {
m_e.printStackTrace();
}
return m_locationMode != Settings.Secure.LOCATION_MODE_OFF;
}else{
m_locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(m_locationProviders);
}
}
permission in menifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
To check Bluetooth enable:
/**
* Method to check if bluetooth enable
*/
public boolean isBluetoothEnabled()
{
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
return m_BluetoothAdapter.isEnabled();
}
permission in menifest:
<uses-permission android:name="android.permission.BLUETOOTH" />