I wrote a script to simulate the user actions. The workflow is, for example, first tap an icon, launch an activity. Then do other actions.
The question is , I don’t know the exact time that the activity launched completely. At present, I use sleep to make my script wait.
Is there any way to know when an activity launched completely?
I wrote a script to simulate the user actions. The workflow is, for example,
Share
Is your final task is to run something after activity is launched… do this
First method called from activity is
onCreate(), Hence we can say completing theonCreate()system callsonStart()which callsonResume()method… asonResume()completes you can say your activity is launched properly…If you are not going to override
onStart()oronResume()what I am going to describe can be written as last statements ofonCreate(). That’s I usually do when I don’t needonStart()oronResume().You can create an object of
Handler. LikeHandler handler = new Handler();Handler has a method
postDelayed()that is called some times after the creating and launching is finished.call it like
handler.postDelayed(runnable,timeInMilliSeconds);after all the processes finish, application will wait for
timeInMilliSecondsms to start the process defined inrunmethod ofrunnableprovided inpostDelayed…..Thus
If your task is to know when the launching is finished the answer is: at the end of
onResume()called from youronStart()….If you want to perform some action use
handler.PostDelayed()method and keeptimeInMilliSecondsvery low… [between 1 to 10].