How do I create an android Intent that carries data?

Use the Intent bundle to add extra information, like so:

Intent i = new Intent(MessageService.this, ViewMessageActivity.class);
i.putExtra("name", "value");

And on the receiving side:

String extra = i.getStringExtra("name");

Or, to get all the extras as a bundle, independently of the type:

Bundle b = i.getExtras();

There are various signatures for the putExtra() method and various methods to get the data depending on its type. You can see more here: Intent, putExtra.

EDIT: To pass on an object it must implement Parcelable or Serializable, so you can use one of the following signatures:

putExtra(String name, Serializable value)

putExtra(String name, Parcelable value)


You can do the following to add information into the intent bundle:

    Intent i = new Intent(MessageService.this, ViewMessageActivity.class);
    i.putExtra("message", "value");
    startActivity(i);

Then in the activity you can retrieve like this:

    Bundle extras = getIntent().getExtras();
    String message = extras.getString("message");