开发者

How to Stop for Button Handler - Android

When I call a buttonHandler, the app just continues i开发者_运维问答n 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 initiateScan and initiateSend work, but it sounds like initiateScan is using startActivity or startActivityForResult to do it's thing.

If so, you need to ensure they are using startActivityForResult, and move initiateSend to the onActivityResult method of your activity.

Activities are asynchronous entities and you need to make use of the onActivityResult callback to handle actions in the linear manner you are looking for.

For more info, read here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜