Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference." at FailDialogs.java:24
I just started diving back into Android/Java after a 5yr layoff so your help will be greatly appreciaded.
public class FailDialogs {
static Context context;
public static void invalidPasswordEmail() {
new MaterialStyledDialog.Builder(context) // <- This would be line 24
.setHeaderDrawable(R.drawable.shot_down)
.withDialogAnimation(true)
.setTitle(context.getString(R.string.dialog_warning))
.setDescription(context.getString(R.string.login_description_failed))
.setPositiveText(context.getString(R.string.login_positive_text_failed))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
/**
* Send the user to the Signup Activity If they
* realize they had not signed up yet or needs to
* create a new account via the action button.
*/
context.startActivity(new Intent(context, RegisterActivity.class));
}
})
.setNegativeText(R.string.login_negative_text_failed)
.show();
}
}
How can I reuse the dialog's in a separate class?
With my attempt, I get a
NullPointerException
:I just started diving back into Android/Java after a 5yr layoff so your help will be greatly appreciaded.
I'm accessing it with
checkIfEmailVerified();