programatically turn on/off gps in android versions 4.x & onwards
<p>The below code works well in android versions 2.x.x. It successfully turns on gps in devices. But the problem is it doesn't work on android versions 4.x onwards.</p>

<p><strong>I am looking to turn on gps programatically in versions 4.x onwards. Any help or solution ?</strong></p>

<pre><code>    String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
        Utility.print("provider string " + provider);
        if (!provider.contains("gps")) { // if gps is disabled
            Utility.print("gps is disabled now enabled");
            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);
            Utility.print("gps is disabled now enabled 1");
        } else {
            Utility.print("gps is already enabled");
        }
</code></pre>
