title: How to ask user to enable GPS at the launch of application?
body: <pre><code>private void turnGPSOn(){
  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>see the Logcat</p>
  
  <pre><code>04/20 17:35:26: Launching app
  $ adb push F:\AndroidProject\Picker\app\build\outputs\apk\app-debug.apk /data/local/tmp/picker.novasyslabs.com.picker
  $ adb shell pm install -r "/data/local/tmp/picker.novasyslabs.com.picker"
      pkg: /data/local/tmp/picker.novasyslabs.com.picker
  Success
  
  
  $ adb shell am start -n "picker.novasyslabs.com.picker/picker.novasyslabs.com.picker.SlashScreen" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  Connected to process 22502 on device sony-d2302-ZH80065A89
  W/ResourceType: Found multiple library tables, ignoring...
  W/ResourceType: Found multiple library tables, ignoring...
  W/ResourceType: Found multiple library tables, ignoring...
  W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  I/art: Background partial concurrent mark sweep GC freed 151(19KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 13MB/22MB, paused 5.156ms total 20.919ms
  D/AndroidRuntime: Shutting down VM
  E/AndroidRuntime: FATAL EXCEPTION: main
                    Process: picker.novasyslabs.com.picker, PID: 22502
                    java.lang.RuntimeException: Unable to start activity ComponentInfo{picker.novasyslabs.com.picker/picker.novasyslabs.com.picker.SlashScreen}: java.lang.ClassCastException: picker.novasyslabs.com.picker.SlashScreen cannot be cast to com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
                        at android.app.ActivityThread.access$800(ActivityThread.java:156)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:211)
                        at android.app.ActivityThread.main(ActivityThread.java:5371)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at java.lang.reflect.Method.invoke(Method.java:372)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
                     Caused by: java.lang.ClassCastException: picker.novasyslabs.com.picker.SlashScreen cannot be cast to com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks
                        at picker.novasyslabs.com.picker.SlashScreen.onCreate(SlashScreen.java:65)
                        at android.app.Activity.performCreate(Activity.java:5990)
                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) 
                        at android.app.ActivityThread.access$800(ActivityThread.java:156) 
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) 
                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                        at android.os.Looper.loop(Looper.java:211) 
                        at android.app.ActivityThread.main(ActivityThread.java:5371) 
                        at java.lang.reflect.Method.invoke(Native Method) 
                        at java.lang.reflect.Method.invoke(Method.java:372) 
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945) 
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740) 
  Application terminated.
  </code></pre>
  
  <p>I tried many other option like package manager, location manager, etc but not able to do what I want.
          I want that at the launch application user will be prompted to enable the GPS.
      I don't want user to go inside the settings.</p>
  
  <p>And that I wanted for the API level >=19.</p>
  
  <p>Please help me to solve my problem.........
  Thanks</p>