android check location services enabled with play services location api

后端 未结 4 453
囚心锁ツ
囚心锁ツ 2021-01-01 11:01

You can determine if any providers are available with LocationManager, but can it be done with the google play services location api?

When nothing is enabled, in fac

4条回答
  •  生来不讨喜
    2021-01-01 11:39

    I've combed the docs and also haven't found any way to use LocationClient to detect if location services are enabled. onConnected, onDisconnected, and onConnectionFailed do not seem to be linked to whether Location Services are enabled or not.

    I'm currently doing location requests using LocationClient, but using the old locationManager.isProviderEnabled(String provider) method to detect if the Location Services are enabled. This is optimal for me, as, even if LocationClient did provide a way, it makes no distinction between GPS and Network and I'd really like to be able to request that the user enable GPS.

    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { 
        //GPS Provider disabled
        return false;
    }
    

提交回复
热议问题