Code example for Fragment

Methods: getRetainInstance, onCreate, setRetainInstance

0
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		self = new WeakReference<LogFragment>(this);
		log = "";
		if (!this.getRetainInstance())
			this.setRetainInstance(true);
		super.onCreate(savedInstanceState);
	} 
 
	protected void logToggle() { 
		boolean state = logToggle.isChecked();
		PrefUtil.writeBoolean(getActivity(), Pref.LOG_KEY.key(), state);
		PrefUtil.notifyPrefChange(getActivity(), Pref.LOG_KEY.key(), state);
	} 
 
	protected void sendLog() { 
		Intent i = new Intent(getActivity(), WifiFixerActivity.class);
		i.putExtra(WifiFixerActivity.SEND_LOG, true);
		getActivity().startActivity(i);
	}