开发者

Android Activity setResult not persistant?

So I was trying a hack to put a quick bandaid on an issue I'm having that's described in another question I have posted.

I have a sub-activity that was kicked off by my main activity and it can also be stopped by the main activity calling finishActivity(requestCode) on it. However the sub-activity is always returning 0 after the finishActivity call - even though I only set that result in the sub-activity if the u开发者_如何学JAVAser presses the back button. I tried to cheat by calling setResult(RESULT_OK) in the sub-activity onResume method, but that seems like it makes no difference;

Also, for some reason it is taking a long time before the onActivityResults come in. Is that normal?

Thanks for any advice!


Observed the same bahaviour. In the main class that calls finishActivity() I had to remember ID of the Activity that I forced to close, so when it returns back in onActivityResult I can distinguish two cases:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_CANCELED) {
        switch (requestCode) {
            case OUTSOURCED_INTENT:
            {
                if(mForcedClosingOfOutsourcedActivity)
                {
                    //Handles case of forced closing
                }
                else
                {
                    //Handles case of normal closing from Activity
                }
            }
            break;
        }
    }
}    

Definitely, it is not OK to wait so long time until Activity close.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜