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.

RuntimeException with @PreferenceScreen #1392

@Noiseapps

Description

@Noiseapps

Hi,
I've tried to implement the preference screen in my app today and stumbled upon this bug (or am I doing something wrong?)

I have created a xml file with preferences, and annotated the activity :

@PreferenceScreen(R.xml.preferences)
@EActivity
public class SettingsActivity extends PreferenceActivity {
}

and it gives me the error:

Caused by: java.lang.RuntimeException: This should be called after super.onCreate.
            at android.preference.PreferenceActivity.requirePreferenceManager(PreferenceActivity.java:1439)
            at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:1511)
            at package.name.SettingsActivity_.init_(SettingsActivity_.java:38)
            at package.name.SettingsActivity_.onCreate(SettingsActivity_.java:32)
            at android.app.Activity.performCreate(Activity.java:5990)

I guess the problem is in the generated class:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        OnViewChangedNotifier previousNotifier = OnViewChangedNotifier.replaceNotifier(onViewChangedNotifier_);
        init_(savedInstanceState); // that line should be after onCreate (line 32)
        super.onCreate(savedInstanceState);
        OnViewChangedNotifier.replaceNotifier(previousNotifier);
    }

    private void init_(Bundle savedInstanceState) {
        addPreferencesFromResource(xml.preferences); // line 38
    }

Is there anyone who can confirm the bug or indicate my mistake (I did everything as in the wiki section, so I think all should be fine)
Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions