how to know if device in high accuracy mode

前端 未结 2 752
面向向阳花
面向向阳花 2021-01-12 12:42

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 impl

2条回答
  •  伪装坚强ぢ
    2021-01-12 13:23

    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

提交回复
热议问题