Code example for Fragment

Methods: getArguments, onAttach

0
	protected ContentObserver mFeedObserver;
	protected Uri mFeedUri;
 
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mFeedObserver = new ContentObserver(new Handler(activity.getMainLooper())) {
            @Override 
            public void onChange(boolean selfChange) {
                onFeedUpdated(); 
            } 
        }; 
        mFeedUri = getArguments().getParcelable(ARG_FEED_URI);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ContentResolver resolver = getActivity().getContentResolver();
        resolver.registerContentObserver(mFeedUri, true, mFeedObserver);
        onFeedUpdated();