Intent.putExtra not working

I need to pass information between two actions, but for some reason the information is not sent / not received.

LogCat does not give me any errors. Dubbing clearly shows that something is added to the intent (variabl: mExtras), but it is difficult to accurately interpret what is added. After that, he gives me a "source not found" and does not help me further.

But first, first. So far, am I doing everything right?

Dispatch

Intent intent = new Intent ( this, TaskListActivity.class );
intent.putExtra ( ProjectManager.ID, mId.toString () );
startActivity ( intent );

RECEIVE:

Intent intent = getIntent ();
mId = UUID.fromString ( intent.getStringExtra ( ProjectManager.ID ) );
+4
source share
5 answers

add the following code after the intention:

Bundle extras = intent.getExtras();
String exampleString = extras.getString(ProjectManager.ID);
+2
source

ProjectManager.ID?, key, putExtra, , , :

Intent intent = new Intent ( this, TaskListActivity.class );
intent.putExtra (ProjectManager.ID, mId.toString () );
startActivity ( intent );

:

Bundle extras = intent.getExtras();
    if(extras!=null){
  String _Str = extras.getString(ProjectManager.ID);
}
+1

Try this to get extra:

Bundle extras = getIntent().getExtras(); 
String id;

if (extras != null) {
    id= extras.getString(key);

}
0
source

In FirstActivity.java write this code.

 Intent i = new Intent(FirstActivity.this,SecondActivity.class);
 i.putExtra("KEY",value);
 startActivity(i);

In SecondActivity.java:

Bundle extras=getIntent().getExtras();
String name=extras.getString("key"); //if data you are sending is String.
int i=extras.getInt("key"); //if data you are sending is integer.
0
source

To get additional features in a new action:

String valueOfExtra;
Intent i = getIntent();
//check first
if(i.hasExtra("extra1")){
  valueOfExtra = i.getStringExtra("extra1");
}
0
source

All Articles