Code example for DialogFragment

Methods: getActivity, onCreate, setRetainInstance

0
		mTask = task;
	} 
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		// Stop the dialog from being destroyed on orientation change 
		setRetainInstance(true);
 
		mTask = new DetectAsyncTask(getActivity().getPackageManager(), this);
		mTask.execute();
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.detector_task_fragment, container);
		mProgressText = (TextView) view.findViewById(R.id.detector_task_fragment_progress_text);
		mProgressBar = (ProgressBar) view.findViewById(R.id.detector_task_fragment_progress_bar);
 
		getDialog().setTitle(R.string.progress_dialog_title);