Dear all,
I searched in Internet that below Java code can turn GPS ON/OFF. How can we transfer to B4A ? I have tested with TurnGPS, Toggle library but not sucess. It is ok with 3G but not sucess with GPS.
JAVA CODE
publicvoid turnGPSOn(){Intent intent =newIntent("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 disabledfinalIntent poke =newIntent();
poke.setClassName("com.android.settings","com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));this.ctx.sendBroadcast(poke);
}}// automatic turn off the gpspublicvoid turnGPSOff(){String provider =Settings.Secure.getString(ctx.getContentResolver(),Settings.Secure.LOCATION_PROVIDERS_ALLOWED);if(provider.contains("gps")){//if gps is enabledfinalIntent poke =newIntent();
poke.setClassName("com.android.settings","com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));this.ctx.sendBroadcast(poke);}}
Regards,
Jonh