deveLost
deveLost

Reputation: 1171

Android : Mistake with Intent and Activities

I've 3 activities A, B and C.

With A, I'm calling B, and with B I'm calling C. (every times with a sample Button).

I wanted to call the Activity A, with the C's button so I wrote that :

Intent intent = new Intent(this, A.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);

It works, but I want to send an information to the A activity. So I added that :

intent.putExtra("id", object.getId());

But in the A Activity, I don't succeed to have this data....

I tried to do that on the A Activity when I call the B Activity :

startActivityForResult(i, 1);

But when I'm on the C activity, and I click on the button, I'm entering in :

onActivityResult

but the Intent data is null. (because it's excepting to be called from B Activity ?)

How can I "give" an information C -> A ?

Thanks,

Upvotes: 2

Views: 37

Answers (1)

Karakuri
Karakuri

Reputation: 38605

Using startActivity() should work. Override onNewIntent(Intent intent) in Activity A and check for the data there.

Upvotes: 2

Related Questions