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 when only optional extras #8

Closed
RoRoche opened this issue Jun 25, 2015 · 1 comment
Closed

NullPointerException when only optional extras #8

RoRoche opened this issue Jun 25, 2015 · 1 comment

Comments

@RoRoche
Copy link

RoRoche commented Jun 25, 2015

Given the following activity:

@IntentBuilder
public class ActivityMain extends Activity {

    @Extra
    @Optional
    public String title;

}

It generates the following builder:

public final class ActivityMainIntentBuilder {
  private String title;

  public ActivityMainIntentBuilder() {
  }

  public ActivityMainIntentBuilder title(String title) {
    this.title = title;
    return this;
  }

  public Intent build(Context context) {
    Intent intent = new Intent(context, ActivityMain.class);
    intent.putExtra("title", title);
    return intent;
  }

  public static void inject(Intent intent, ActivityMain activity) {
    Bundle extras = intent.getExtras();
    activity.title = (String) extras.get("title");
  }
}

But, when calling the method ActivityMainIntentBuilder.inject(getIntent(), this);, the application crashes on the extras.get("title") instruction because of extras nullity in the inject method.

@emilsjolander
Copy link
Owner

Good catch. This has been fixed on master and is currently syncing up to jcenter

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