Reputation: 1063
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.
Upvotes: 0
Views: 749
Reputation: 4036
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_;
}
}
Upvotes: 0
Reputation: 4658
Pass data through intents as extras. USe .putExtra and just pass from B to C.
Upvotes: 1
Reputation: 24031
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.
Upvotes: 1