-1

I'm trying to display the login on the navigation drawer header , it worked fine when I used this piece if code

Bundle b = getIntent().getExtras();
name.setText(b.getCharSequence("username"));

But when I tried going back to the navigation drawer from another activity using the back arrow my app crashes my logcat says null pointer exception on this line

name.setText(b.getCharSequence("username"));

P.S the username is name of the variable on my php code.. help

Sanjog Shrestha
  • 827
  • 9
  • 16
Akramqq
  • 11
  • 3

1 Answers1

1

It might likely be that you might have finished yourActivity.class and starting other activity. Now when you press back button, you might have started the activity with contains the code. Here you might have missed to provide the username in the intent. Thus, in your activity - the null reference is pointed your textView resulting in NPE.

Sanjog Shrestha
  • 827
  • 9
  • 16