Skip to content Skip to sidebar Skip to footer

Android - Testing If Another Activity Has Started

I am trying to test the following scenario, enter a letter in the autocomplete textview, scroll down and select one of the options, then click a button, The button click starts a n

Solution 1:

You'll need to use the ActivityManager as conveniently demonstrated here: https://stackoverflow.com/questions/3908029/android-get-icons-of-running-activities

The short summary:

ActivityManageram= (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE);
List<ActivityManager.RecentTaskInfo> processes = am.getRecentTasks(5);

gets you a list of all the running processes (you'll need the GET_TASKS permission). You can search through that list for your Activity: one of those tasks should have an origActivity property with the same name as your Activity.

Post a Comment for "Android - Testing If Another Activity Has Started"