private void turnGPSOn(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(!provider.contains(\"gps
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. ;)