Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to see if a sub-activity was started or not
    primarykey
    data
    text
    <p>I'm writing a unit test for an Android application.</p> <p>I'd like to see if clicking a button will open a correct sub-activity or not.</p> <p>There is a main activity, and within it, there are two buttons, each of which launches a sub activity when clicked.</p> <p>I think the problem happens because these are sub-activities.</p> <p>So, this is the test method in my unit test case.</p> <pre><code>@UiThreadTest public void testActivityLaunch() { //Launches a subActivity theButton.performClick(); ActivityManager am = (ActivityManager) mActivity.getSystemService(Service.ACTIVITY_SERVICE); List&lt;RunningAppProcessInfo&gt; procInfos = am.getRunningAppProcesses(); List&lt;ActivityManager.RecentTaskInfo&gt; processes = am.getRecentTasks(5, ActivityManager.RECENT_WITH_EXCLUDED); } </code></pre> <p>I set up a breakpoint and looked into both procInfos and processes, and I can't see the name of the subActivity.</p> <p>I created a similar method in the app that is being tested, and I still couldn't see the name of the sub-activity in the list even after it was launched.</p> <p>I just need an access to the name of sub-activity in the process list just to know if a button click has launched it properly or not. Is there any other way to test this?</p> <p>I'd not like to use any other frameworks, such as Robotium, other than what's provided in ADK.</p> <p>EDIT: I'm not sure if this is a sub-activity after all. I just read an article saying it is considered a sub-activity if it is started with startActivityForResult(). On the button click listener I'm starting it with startActivity().</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload