I have a simple Android Fragment CreateAccountBookingFragment
which inherits from CreateAccountFragment
, that has the following method :
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
passwordTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
onSignUpClick();
}
return false;
}
});
}
method onSignUpClick()
is overridden in CreateAccountBookingFragment
.
Recently there was a bug caught :
java.lang.NullPointerException
at com.myapp.ui.auth.CreateAccountBookingFragment.onSignUpClick(CreateAccountBookingFragment.java:82)
at com.myapp.ui.auth.CreateAccountFragment$1.onEditorAction(CreateAccountFragment.java:83)
at android.widget.TextView.onEditorAction(TextView.java:4594)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:297)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
I quite don't understand how it could throw NullPointer
. It means that inner class is still alive and outer is not ? I though it's impossible. Can anyone help me understand what's going on here ? And what will be the solution to this. Any help appreciated. Thanks.
Device the bug occurred : Samsung GT P3113
Update :
method onSingUpClick()
is here :
@SuppressWarnings("unused")
@OnClick(R.id.frag_auth_sign_up_btn) // line 82, this is ButterKnife annotation
protected void onSignUpClick() {
String email = emailText.getText().toString().trim();
String password = passwordText.getText().toString().trim();
int errorMsg = 0;
if (TextUtils.isEmpty(email)) {
errorMsg = R.string.enter_email;
} else if (!Utils.isValidEmail(email)) {
errorMsg = R.string.invaild_email;
} else if (TextUtils.isEmpty(password)) {
errorMsg = R.string.enter_password;
} else if (!Utils.isValidPassword(password)) {
errorMsg = R.string.invaild_password;
} else if (!NetworkUtils.isNetworkConnected(getActivity())) {
errorMsg = R.string.network_not_connected;
}
if (errorMsg > 0) {
ViewUtils.getInfoDialog(getActivity(), errorMsg).show();
} else {
showLoadingDialog();
signUp(email, password);
}
ViewUtils.hideKeyboard(getActivity());
}