Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know if device in high accuracy mode

Tags:

android

How can we know if the device is in high accuracy mode.

When the Google map is opened in device only mode it ask you to change to high accuracy mode. I need to implement such a thing. But i couldn't find any API that let us know the location mode.

update: i need to know this from code. i need to know if the device is currently in the device only mode, battery saver mode or high accuracy mode

like image 538
null pointer Avatar asked Sep 09 '14 11:09

null pointer


People also ask

What is high accuracy mode?

Android's location tracking uses wifi, bluetooth and cell towers by default to triangulate your location. By switching to High Accuracy location mode, your Android phone will use GPS satellites in addition to wifi, bluetooth and cell towers to improve your accuracy.

What is high accuracy location?

High accuracy: Use GPS, Wi-Fi, mobile networks, and sensors to get the most accurate location. Use Google Location Services to help estimate your phone's location faster and more accurately. Battery saving: Use sources that use less battery, like Wi-Fi and mobile networks.


1 Answers

In 4.4 KITKAT

Go to settings>location

Default is Device only

enter image description here

Press on MODE

enter image description here

there are three options

make changes as per need

update (through code)

if u want to set

mLocationRequest=LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

if u want to know

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
    try {
        locationMode = Settings.Secure.getInt(context.getContentResolver(),Settings.Secure.LOCATION_MODE);

        } catch (SettingNotFoundException e) {
        e.printStackTrace();
        }

    return (locationMode != Settings.Secure.LOCATION_MODE_OFF && locationMode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); //check location mode

}else{
    locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    return !TextUtils.isEmpty(locationProviders);
}

regards maven

like image 152
Maveňツ Avatar answered Sep 22 '22 06:09

Maveňツ