Issue
I have one activity calling another. But it keeps giving me the error "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference".
Calling activity:
Intent intent1 = new Intent (this, buisnessProfileEdit.class);
Bundle data1 = new Bundle();
data1.putString("Restaurant Username",restaurantUsername);
startActivity(intent1);
Called activity:
Intent intentReceived = getIntent();
Bundle data = intentReceived.getExtras();
restaurantUsername = data.getString("Restaurant Username");
Can someone help me out why this is happening?
Solution
You have to add the extras to the actual Intent:
Intent intent1 = new Intent (this, buisnessProfileEdit.class);
Bundle data1 = new Bundle();
data1.putString("Restaurant Username",restaurantUsername);
intent1.putExtras(data1);
startActivity(intent1);
(PS: you have a typo in buisnessProfileEdit.)
Answered By - CounterFlame
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.