I am trying to enable/disable (toggle) GPS programmatically in my app via a button click, but it is not working. Please help. My target devices are not rooted.
Here\'s t
// location manager
LocationManager locationManager; LocationListener locationListener;
obj_tgl_gps.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
if (obj_tgl_gps.isChecked())
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
else
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", false);
sendBroadcast(intent);
}
}
});