When I call a buttonHandler, the app just continues in the background even though the Handler didn’t finish, how can I stop this behaviour, and fall back to a linear execution?
qrscan.setOnClickListener( new View.OnClickListener() { //the Button listener
public void onClick(View view) { //the handler
if(initiateScan(activity) == null) //first thing i expect it to execute
initiateSend(activity); //the next thing which should be executed AFTER
}
}
);
You aren’t saying much – we’ll need to know how
initiateScanandinitiateSendwork, but it sounds likeinitiateScanis usingstartActivityorstartActivityForResultto do it’s thing.If so, you need to ensure they are using
startActivityForResult, and moveinitiateSendto theonActivityResultmethod of your activity.Activities are asynchronous entities and you need to make use of the
onActivityResultcallback to handle actions in the linear manner you are looking for.For more info, read here.