getCurrentActivity() method of UiDevice class in Uiautomator api

2,902 views
Skip to first unread message

Armaan

unread,
Apr 26, 2013, 3:02:35 AM4/26/13
to adt...@googlegroups.com
The getCurrentActivity() method of UiDevice class in Uiautomator api is deprecated. May i please know the reason. Also the documentation says that the results should be considered unreliable. What problems/complications can occur if it is used / relied upon?

Guang Zhu

unread,
Apr 29, 2013, 11:26:38 PM4/29/13
to adt...@googlegroups.com
Hello,

The current implementation reads the text info associated with the accessibility event that indicates a frontend window change, and this may or may not match the label (as declared in manifest) of the underlying activity.

Another way to match/verify whether the foreground window is the desired activity is to use a combination of package name and text of a visible UI element that can reasonably distinguish the activity in question from others.

Thanks,
Guang Zhu


On Fri, Apr 26, 2013 at 12:02 AM, Armaan <sanch...@gmail.com> wrote:
The getCurrentActivity() method of UiDevice class in Uiautomator api is deprecated. May i please know the reason. Also the documentation says that the results should be considered unreliable. What problems/complications can occur if it is used / relied upon?

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Guang Zhu
Android Test Engineering
Google Inc.

Please keep all discussions on related Google Groups, no direct emails. Thanks!

Armaan

unread,
May 2, 2013, 5:56:08 AM5/2/13
to adt...@googlegroups.com
Thank you sir for the reply. 

Can you please help me out regarding this issue. Is there any other reliable way to get the current activity name in Uiautomator test cases.
Thanks.

Armaan

unread,
May 2, 2013, 6:06:12 AM5/2/13
to adt...@googlegroups.com
The approach you mentioned in the second paragraph of your first reply would require changes in programming methods by developers so that a unique combination can be developed for each activity. This approach may not be efficient and helpful in the long run and it also beats the purpose of Uiautomator which provides all the information associated with the ui  itself.
Is there any other reliable way/solution to know the name of the current activity on the screen. Any help would be greatly appreciated.
Thank you.



On Friday, April 26, 2013 12:32:35 PM UTC+5:30, Armaan wrote:

Guang Zhu

unread,
May 6, 2013, 2:33:10 PM5/6/13
to adt...@googlegroups.com
As a black box testing approach, you should not need to know the underlying activity class name, because such information is normally not known unless you look into source code of the application.

When you look at an Android activity, you know which UI screen of the app under test it is, because you recognize the specific title, text or arrangement of UI. I was not suggesting that you should put special elements on your app UI to help test case identify which activity it is; instead, I was suggesting that such matching should be based on existing UI elements of the specific activity that you are trying to capture.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages