I have a project in Android
in which I send the value of a variable from Adapter
to Activity
like this:
public void onClick(View v) {
Intent inicioIntent = new Intent(context, Activity2.class);
inicioIntent.putExtra("idU", idUser);
context.startActivity(inicioIntent);}
And in the Activity I receive it like this:
protected void onCreate(Bundle savedInstanceState) {
idGestor = intent.getExtras().getString("idG");}
Then the Activity happened to Activity2 , but when I return the app stops and it marks me an error just in the line where I receive the value of the variable.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.BaseBundle.getString (java.lang.String) 'on a null object reference
I guess you mark it because I'm not sending the value from Activity2 to Activity , but from Adapter to Activity strong>, but that value is supposed to exist already.