How to ask user to enable GPS at the launch of application?

前端 未结 5 793
我在风中等你
我在风中等你 2020-12-31 10:49
private void turnGPSOn(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

if(!provider.contains(\"gps         


        
5条回答
  •  误落风尘
    2020-12-31 10:56

    Image of GPS permission like Google Maps

    If you want to ask permission like shown in the above link, you can refer to my answer: https://stackoverflow.com/a/64757407/10618364

    Code is written with GoogleApi and SettingsClient API, not with deprecated GoogleClientApi and SettingsApi.

    It is also compatible with Android 11. ;)

提交回复
热议问题