title: How to turn on the GPS Programmatically on Android App
body: <p>Please help me to turn on GPS in my mobile app like OlaCabs..
  I am using below code:</p>
  
  <pre><code>String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
  
  if(!provider.contains("gps")){ //if gps is disabled
      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);
  }
  </code></pre>
  
  <p>But it's not able to turn on GPS..</p>