プログラムでGPSを有効/無効にする場合はこれ を参照し、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 パーミッション:
<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"/>