Code example for ListFragment

Methods: getActivity, onPause

0
 
	/** 
	 * Unregister the external storage BroadcastReceiver. 
	 */ 
	private void stopWatchingExternalStorage() { 
		getActivity().unregisterReceiver(this.mExternalStorageReceiver);
	} 
 
	/** 
	 * Respond to a change in the external storage state 
	 * 
	 * @param available 
	 * @param writeable 
	 */ 
	private void handleExternalStorageState(boolean available, boolean writeable) {
		if (!available && isIntentGetContent()) {
			if (DEBUG) Log.d(TAG, "External Storage was disconnected");
			onFileDisconnect(); 
			//TODO 
			listener.onMediaUnmounted();
		} 
	} 
 
	/** 
	 * Called when a file is successfully selected by the user. 
	 * 
	 * @param file The file selected. 
	 */ 
	protected void onFileSelect(File file) {
		if (DEBUG) Log.d(TAG, "File selected: " + file.getAbsolutePath());
	} 
 
	/** 
	 * Called when there is an error selecting a file. 
	 * 
	 * @param e The error encountered during file selection. 
	 */ 
	protected void onFileError(Exception e) {
		if (DEBUG) Log.e(TAG, "Error selecting file", e);
	} 
 
	/** 
	 * Called when the user backs out of the file selection process. 
	 */ 
	protected void onFileSelectCancel() { 
		if (DEBUG) Log.d(TAG, "File selection canceled");
	} 
 
	/** 
	 * Called when the external storage (SD) is disconnected. 
	 */ 
	protected void onFileDisconnect() { 
		if (DEBUG) Log.d(TAG, "External storage disconnected");
	} 
 
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		// Get the external storage directory. 
		this.mExternalDir = Environment.getExternalStorageDirectory();
 
		if (getListAdapter() == null) {
			// Assign the list adapter to the ListView 
			setListAdapter(new FileListAdapter(getActivity()));
		} 
	} 
 
	@Override 
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
 
		if (savedInstanceState != null) {
			restoreMe(savedInstanceState);
		} else { 
			// Set the external storage directory as the current path 
			this.mPath = this.mExternalDir.getAbsolutePath();
			// Add the current path to the breadcrumb 
			updateBreadcrumb(true); 
			fillList(0); 
		} 
 
 
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.explorer, container, false);
	} 
 
 
	@Override 
	public void onResume() { 
		super.onResume(); 
		// Set the Broadcast Receiver to listen for storage mount changes 
		startWatchingExternalStorage(); 
	} 
 
	@Override 
	public void onPause() { 
		super.onPause(); 
		// Remove the Broadcast Receiver listening for storage mount changes 
		stopWatchingExternalStorage(); 
	} 
 
	@Override 
Connect your IDE to all the code out there  Get Codota for Java