So I have a problem and I am wondering how to solve it if it can be solved at all.
I have an external library class called Messenger that defines the method sendMessage(String msg). I also have the following MessengerManager class
public class MessengerManager{
private Messenger messenger;
public MessengerManager(Context context){
messenger = new Messenger(context);
}
public void message(){
String msg = "12435";
messenger.sendMessage(msg);
// Do more stuff
.....
.....
.....
}
}
So the issue is that sendMessage runs asynchronously and starts a new activity. Hence, the code after sendMessage ("Do more stuff") gets run immediately. However, I need to wait for the call to sendMessage to return to carry on with the "Do more stuff".
As sendMessage is a method defined in an external library, I cannot change it in any way nor do I have access to its source code.
I looked at the start startActivitySync method in instrumentation but that seems to return as soon as the activity's constructer is called. That does not work for me. I need to wait till the entire activity started by sendMessage is finished. Anyone know how to solve this?
0 comments:
Post a Comment