Android Activity Life Cycle

后端 未结 1 800
轮回少年
轮回少年 2021-01-26 01:04

Activity 1 starts Activity 2 with a button click. Once the static content for Activity 2 is set and displayed to the user, I want to kick off an AsyncTask. In the execution of t

1条回答
  •  深忆病人
    2021-01-26 01:54

    Why is it important that activity two be in the background while this AsyncTask is running in the background? The user is going to be shown a dialog regardless... Why don't you put a flag in the AsyncTask, and wait to set the flag and display the dialog until the onResume() method has finished executing. Or you could try calling a static start method from activity one when activity. Perhaps by calling finish() and then overriding the onDestroy() method. Its hard to get that timing..

    0 讨论(0)
提交回复
热议问题