Take the 2-minute tour ×

I have three activities A,B,and C.

I go from Activity A -> Activity B -> Activity C Now currently Activity C is displaying and Activity A is bottom on Activity Stack then I provide some inputs to Activity C through which the another thread send some data to Handler of Activity A.

Now I want to receive that data on my Activity C.

Can any possible solution ? Should I use intent and if yes then can u give me appropriate guidance ?

Thanks in Advance.

share|improve this question
add comment

3 Answers

If data is for decision purpose only then you can use static or SharedPreference and use handler to notify that the data has come or changed.

share|improve this answer
If I do not want to use shared preference then and how static variable can be use because i donot know when will the data arrived on firstactivity handler.. –  Mak Sep 29 '11 at 14:06
you need to set the handler of activity C to activity A thru setter and when you get the data in activity A's handler, notify activity C thru it's handler..... –  Vineet Shukla Sep 29 '11 at 14:13
add comment

Pass data through intents as extras. USe .putExtra and just pass from B to C.

share|improve this answer
If I am already on Activity C then how can I pass data of Activity A to Activity C through Intents.(I know that if we start Activity from one Activity then we can pass intent through StartActivity(Intent) but here our Activity already started..) –  Mak Sep 29 '11 at 14:03
Misunderstood the question. –  Mike dg Sep 29 '11 at 14:05
You can send a broadcast, but you probably shouldn't be running a long executing Thread as a member of an old Activity. Look into a service and then either bind the service and set a listener in Activity A and C, or send broadcasts on certain events. –  Mike dg Sep 29 '11 at 14:07
yes it is probably what I want. –  Mak Sep 29 '11 at 14:11
i have another thing to ask i didn't use any broadcast yet then for this purpose it is only the solution . –  Mak Sep 29 '11 at 14:12
add comment

It sounds like you are trying to pass massages from one to activity to the other. You can use a singleton class to do that. Here is a skeleton you can use

// Singleton Class for message passing
public class Messenger {

    private static Messenger instance = new Messenger();

    public static Messenger get() {
        return instance;

    private String  theMessage_;

    // Default Constructor
    private Messenger() {

     // Setter to set the message you want to pass
    public void setMessageToBePassed(String myMessage){
        theMessage_ = myMessage;

    // Getter to get the message that is passed to you
    public String  getMessage(){
        return theMessage_;

share|improve this answer
add comment

Your Answer


