Reputation: 787
I have a Contact Activity which is derived from ListActivity, which displays list of contacts, and on click of item, a new Activity Message Activity derived from ListActivity is initialized.
Now I know, I can pack some information in Bundle and pass it before creating activity, but is there a way I can get instance of "ContactActivity" in onCreate method of "MessageActivity"?
Upvotes: 5
Views: 9890
Reputation: 61
Yes there is, you can do a workaround. In your message Activity declare a static attribute of the type of your contact class, then you set that attribute with the selected contact when the list is clicked and then you start your message activity. When onCreate is executed in your message activity you can use that attribute.
Upvotes: 6
Reputation: 1006859
No, sorry, there is no built-in means for you to get at the activity that called startActivity()
for your current activity. After all, the original activity might not be in your application (e.g., home screen).
Upvotes: 4