private void toggleGPS() {
Intent gpsIntent = new Intent();
gpsIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
gpsIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(this, 0, gpsIntent, 0).send();
// this.sendBroadcast(gpsIntent);
} catch (CanceledException e) {
e.printStackTrace();
}
}
Hi, please check above code which intends to toggle Android phone's GPS. But it seems not work on my Galaxy S3. Could anyone points out what is wrong with it?
The second question is that someone tries to analyse the source code of SettingsAppWidgetProvider.java. But I cannot find where it is, does anyone know?
Thanks!