when my sales guys access my c#.net website/web application through browser, it will send the GPSco-ordinates to the server only if the GPS tuned on, but occasionally i am facing problem when my agents turning off the gps on their android tablets, so i am thinking of turning their GPS ON grammatically , can any one please help me how can i achieve that one Thanks
Asked
Active
Viewed 504 times
1 Answers
0
Create a thread that constantly checks for a value in your webservice like GPS status=true/false
and call this function when the value is turned true
public void turnGPSOn()
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
this.ctx.sendBroadcast(intent);
String provider = Settings.Secure.getString(ctx.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"));
this.ctx.sendBroadcast(poke);
}
}
and add Permissions in the manifest too

Virag Brahme
- 2,062
- 1
- 20
- 32

insomniac
- 11,146
- 6
- 44
- 55
-
I don't think you understand my question/situation. I need to do it from my aspx page either by using some kind of script, – Srikanth Dec 05 '13 at 13:00
-
I don't think that is possible unless you have an android app that has the permission to change GPS setting in the client device – insomniac Dec 06 '13 at 03:39