0

I recently saw this app on the Google Play

https://play.google.com/store/apps/details?id=com.androidlost&hl=fr

I was particularly interested to know how does it do that kind of stuff ?? (knowing that for security reasons you can't do it with the Android SDK normally...)

* start/stop GPS
* start/stop WIFI

Is there any kind of trick to allow this to be possible ?

Thank you

Wesley Wiser
  • 9,491
  • 4
  • 50
  • 69
Alexis
  • 1,825
  • 4
  • 23
  • 28

1 Answers1

1

for Enable/Disable GPS programatically see this and for Wifi :

String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
final Intent poke = new Intent();
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); 
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
 poke.setData(Uri.parse("0")); 
int wifistatus = ((WifiManager)con.getSystemService(Context.WIFI_SERVICE)).getWifiState();
if(wifistatus==1)  //if WIFI is disabled
{
sendBroadcast(poke);
}
else //if WIFI is enable
{
sendBroadcast(poke);
}

manifest.xml permission :

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission  android:name="android.permission.ACCESS_WIFI_STATE"/>
Community
  • 1
  • 1
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213