I am developing an android application and I want to create a condition in an if statement in my first activity, say Activity A that checks if that activity (e.g. Activity A) has been triggered by an intent from another Activity (say Activity B) and then do something. So if I was to trigger Activity A from say Activity C for example the if statement in Activity A wouldn't execute the code inside the if statement. I haven't written any code for it because I don't know how to approach it. I've written only pseudo code to demonstrate what I want to do.
class Activity A {
if(Activity A was triggered by an intent from Activity B)
{
do something
}
}
Help would be most appreciated thank you.
-
Please accept an answer if one of them helped.thegrinner– thegrinner2011年07月27日 14:22:58 +00:00Commented Jul 27, 2011 at 14:22
2 Answers 2
'putExtra()' in B and C and '.getExtras()' in A would be the easiest way. Have a look at steps 5 an 6 in
(Plus you ought to check that the extras aren't null in Activity A to be on the safe side)
Comments
You could also use startActivityForResult and then use onActivityResult to execute the code on return from whichever activity.