java - NullPointerException on bigger screen devices -


this question has answer here:

when run app on motorola nexus 6 , nullpointerexception.problem 1 textview , setting text on same.i saw solutions online, none of them worked me.i guess problem jvm on different smartphones, or lifecycle of fragment nested inside activity.

everything working fine on smaller devices.

log bellow:

  java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string com..data.models.entity.email.getusername()' on null object reference                                                      @ com..presenter.view.fragment.forgotpasswordfragmentcomplete.onstart(forgotpasswordfragmentcomplete.java:84) 

here fragment:

 @bind(r.id.button_resend_email)     appcompatbutton resendemail;     @bind(r.id.resend_user_email)autoresizetextview resendemailtxt;    @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          daggerforgotpasswordcompletedcomponent.builder()                 .applicationcomponent(                         ((androidapplication) getactivity().getapplication()).getapplicationcomponent())                 .forgotpasswordcompletedmodule(new forgotpasswordcompletedmodule())                 .build()                 .inject(this);       }      @override     public void onstart() {         super.onstart();          realm = getrealm();         realmquery<email> query1 = realm.where(email.class);         email result1 = query1.findfirst();          resendemailtxt = (autoresizetextview) getview().findviewbyid(r.id.resend_user_email) ;          this.resendemailtxt.settext(result1.getusername());      }      @override     public void ondestroy() {         super.ondestroy();         realm.close();       }        @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {          return inflater.inflate(r.layout.fragment_forgot_password_fragment_complete, container, false);       }       @override     protected int getfragmentlayoutid() {         return r.layout.fragment_forgot_password_fragment_complete;     } 

if nullpointerexception means result1 variable has not been assigned value. implies query1.findfirst() may returning nothing @ all.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -