GPS isProviderEnabled always return false

android, gps, provider, return

Solution

try this way..

private void turnGPSOn(){   
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);   
if(!provider.contains("gps")){      
    final Intent poke = new Intent();  
    poke.setClassName("com.android.settings","com.android.settings.widget.SettingsAppWidgetProvider");           
    poke.addCategory(Intent.CATEGORY_ALTERNATIVE);   
    poke.setData(Uri.parse("3"));      
    sendBroadcast(poke);  
    } 
}  

Problem

I've got this code ``` lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean isGPS = lm.isProviderEnabled (LocationManager.GPS_PROVIDER); ``` and it always return false, even when GPS is enabled. GPS is working correctly but I'm using this boolean value to show pop-up "No GPS enabled". In this situation pop-up is showing up every time - I checked similar questions but it doesn't help me. - Yes, i have permission in my manifest - I'm using this code in onResume method Thanks for help.

Original source