Skip to content

IgnoredWhenDetached

Csaba Kozák edited this page Sep 1, 2014 · 1 revision

Since AndroidAnnotations 3.1

When used standalone in an @EFragment or in conjunction with the @UiThread or @Background annotations, the annotated method will be wrapped in an 'if attached' block such that no code will be executed if the @EFragment is no longer bound to its parent activity.

Should be used on method that must meet the following criteria:

  1. Can only be used in conjunction with classes annotated with @EFragment
  2. The annotated method must return void and may contain parameters.

Usage example:

@EFragment
public class LoaderFragment extends Fragment {

    [...]

    @UiThread
    @IgnoredWhenDetached
    void killActivity() {
        getActivity().finish();
    }

    @IgnoredWhenDetached
    void updateTitle(String title) {
        getActivity().setTitle(title);
    }
}

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Clone this wiki locally