Search code examples
androidadbandroid-uiautomator

How can I dump the whole screen when using ADB?


I am trying to get the Hierarchy of the whole screen using ADB.

If I used adb shell uiautomator dump, I only get the current view and not the whole screen. For example if I dump the current view, and I scroll down and dump again, I will get a different output. I want to dump the whole screen without having to scroll down and dump again.


Solution

  • if I am using the gmail app, in my inbox I have a list of emails that are currently in my view. Dumping will only give me that list of email, I want to know if there is a way of getting all emails in my inbox.

    Generally, no.

    Using your Gmail example, suppose that the Gmail app is showing the conversations in some label, and that label contains 343,140,189 conversations.

    (spam, amirite?)

    I am guessing that you think that the UI of the Gmail app has a scrolling list with 343,140,189 rows in it, and that scrolling just changes which of those 343,140,189 rows are visible.

    That is not the case, for lots of reasons, such as the app running out of memory.

    Most scrolling lists in Android use classes like RecyclerView and ListView. These classes recycle their rows. So, instead of 343,140,189 rows, there will be a handful, enough to fill the screen and perhaps a couple more. As the user scrolls, and rows roll off the screen, they get recycled: populated with new content and fed in as "new" rows. Visually, the effect is indistinguishable from having 343,140,189 rows. From a programming standpoint, the difference is significant. And from a uiautomator standpoint, the programming is what matters.