Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

The onPrepareOptionsMenu method may be called before Bean-objects injection. #1308

@maximzhemerenko

Description

@maximzhemerenko

Usually onPrepareOptionsMenu method is called after all bean-objects have been injected, but in Android 4.1.1, 4.1.2 and possibly in other versions it happens vice versa.
This unexpected behavior may cause NullPointerException.

Method init_(Bundle savedInstanceState) (in generated class that extends Activity or Fragment) calls setHasOptionsMenu(true), which may have different implementations in various Android versions.
In this case it calls onPrepareOptionsMenu method immediately, but in Android 4.2+ versions onPrepareOptionsMenu call is postponed.
That's why it would be better to improve AndroidAnnotations lib to exclude calling onPrepareOptionsMenu method before bean-objects (and others) are injected.

In development we are using AndroidAnnotations version of 3.2.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions