我的应用程序中有一个android开关,它隐藏了应用程序绘制中的图标。问题是隐藏和启用需要很长时间。
public static class MyPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.drawer_icon);
PreferenceManager preferenceManager = getPreferenceManager();
if (preferenceManager.getSharedPreferences().getBoolean("drawer_icon", true)) {
PackageManager p = getActivity().getPackageManager();
ComponentName componentName = new ComponentName(getActivity(), com.dfuse.brokenswitcher.LaunchIconActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} else {
int newState;
newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
PackageManager pm = getActivity().getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(getActivity(), LaunchIconActivity.class), newState, PackageManager.DONT_KILL_APP);
}
}
}
}