Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException on Presenter#onViewAttached while using android.app.Activity #34

Closed
RiccardoM opened this issue Mar 17, 2017 · 1 comment

Comments

@RiccardoM
Copy link

Bug
Today I found out that the following code produces a NullPointerException:

public class WebViewActivity extends android.app.Activity implements WebViewActivityView {
    @Presenter WebViewActivityPresenter presenter;
}

How to replicate
The exception can be replacated as follows:

  1. Start the activity.
  2. Rotate the screen.

At this point, the following exception is thrown:
ComponentInfo: java.lang.NullPointerException: Attempt to invoke virtual method 'void WebViewActivityPresenter.onViewAttached(WebViewActivityView)' on a null object reference

How to avoid
I've found out that if android.support.v7.app.AppCompatActivity is used instead of android.app.Activity, then the exception won't be thrown, and everything executes smoothly.

I think that this is a pretty big bug, which may cause a lot of problems, and should be solved as soon as possibile. @SaeedMasoumi

@SaeedMasoumi
Copy link

@RiccardoM Yeah there is an issue while using Loader inside android.app.Activity. I didn't found any solution on the web and people suggested to use AppCompatActivity instead.

Also see these two tests, SimpleActivity and SimpleAppCompatTest
EasyMVP generates same codes for these two classes but the problems is the Loader manager in android.app.Activity, the AppCompatActivity replaced his own manager. I don't know it's fixed in new android releases or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants