清除应用的数据和关闭Wifi、BT、GPS,及清除wifi密码和wifi热点

am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);  
adapter = BluetoothAdapter.getDefaultAdapter();

showDialog(DIALOG_MULTIPLE_CHOICE_DELETE);
if (mClearDataObserver == null) {
 mClearDataObserver = new ClearUserDataObserver();
 }


//clear Contacts
am.clearApplicationUserData("com.android.providers.contacts", mClearDataObserver);

// SMS,Mms
am.clearApplicationUserData("com.android.providers.telephony", mClearDataObserver);

// Media
am.clearApplicationUserData("com.android.providers.media", mClearDataObserver);

// Settings
am.clearApplicationUserData("com.android.settings", mClearDataObserver);

// Calendar
am.clearApplicationUserData("com.android.providers.calendar", mClearDataObserver);

// Application
am.clearApplicationUserData("com.android.providers.applications", mClearDataObserver);

// Download
am.clearApplicationUserData("com.android.providers.downloads", mClearDataObserver);

// clear wifi saveconfig
List<WifiConfiguration> config = (List<WifiConfiguration>) wifiManager.getConfiguredNetworks();
for(int i = 0; i < config.size(); i++){
wifiManager.removeNetwork(config.get(i).networkId);
}
wifiManager.saveConfiguration();

// close wifi
if ((wifiManager != null) && (wifiManager.isWifiEnabled())) {
wifiManager.setWifiEnabled(false);
}

// close wifiap
WifiConfiguration wifiap = wifiManager.getWifiApConfiguration();
wifiap.SSID = getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
wifiManager.setWifiApConfiguration(wifiap);
wifiManager.saveConfiguration();

if(wifiManager.WIFI_AP_STATE_ENABLED == wifiManager.getWifiApState()){
wifiManager.setWifiApEnabled(wifiap, false);
}

// close bluetooth
if((adapter != null) && (!(adapter.getState() == BluetoothAdapter.STATE_OFF))){
adapter.disable();
}

//close GPS
Settings.Secure.setLocationProviderEnabled(getContentResolver(),

LocationManager.GPS_PROVIDER, false);


class ClearUserDataObserver extends IPackageDataObserver.Stub {
       public void onRemoveCompleted(final String packageName, final boolean succeeded) {
      Log.v(TAG, "[yeez_jinwei]succeeded = " + succeeded);
        }
    }

你可能感兴趣的:(service,null,delete,dialog,sms,BT)