How to switch GPS state just like "Quick Settings" does?
<p>I would like to switch the GPS status in my application. The method I know is to modify the secure setting of device like the following code</p>

<pre><code>Settings.Secure.putString(resolver, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, newAllowedProviders);
</code></pre>

<p>However, modifying secure setting is only available in the full rooted devices. If not, it will throw exceptions, even I have add this permission in the <code>AndroidManifest.xml</code>.</p>

<pre><code>java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
</code></pre>

<p>Recently, I discovery an open source application "Quick settings" is able to do it on an non full rooted device, however the author did not release the code of this part. The reason is that he is using some kind of android exploits, he is not willing to release it.</p>

<p>Does any body know how he achieve it?</p>

<hr>

<p>The method that quick settings released is the same method above (modify the security setting). It works, but only in the full rooted device. </p>

<p>However, the real method that quick setting currently used is not released in it's source code, which could work on both root and unroot phone.</p>
