If you want to do it from another tool, it's pretty easy. Run the following commands from a shell:
Make sure you have a dev device/emulator (if you see "1", you're out of luck): $ adb shell getprop ro.secure 0 Start the server: $ adb shell service call window 1 i32 4939 You should see the following result (the "1" means the server is running): Result: Parcel(00000000 00000001 '........') Install the port forwarding: $ adb forward tcp:4939 tcp:4939 Connect to the server: $ telnet localhost 4939 Now, you can use one of two commands (type enter after each command): - LIST will show the list of windows: LIST 43514758 com.android.launcher/com.android.launcher.Launcher 4359e4d0 TrackingView 435b00a0 StatusBarExpanded 43463710 StatusBar 43484c58 Keyguard DONE. - DUMP will show the views and their properties for a given window. For instance, DUMP 43514758 will show the views contained in the window com.android.launcher/com.android.launcher.Launcher. You can also use DUMP -1 or DUMP ffffffff to dump the foreground window. I recommend that version. The dump may take a while go be generated and it looks like this: DUMP -1 com.android.internal.policy.impl.keyguardviewmanager$keyguardviewh...@434d8220 getDescendantFocusability()=24,FOCUS_BEFORE_DESCENDANTS getPersistentDrawingCache()=9,SCROLLING isAlwaysDrawnWithCacheEnabled()=4,true isAnimationCacheEnabled()=4,true isChildrenDrawnWithCacheEnabled()=5,false mMinWidth=1,0 mMinHeight=1,0 mMeasuredWidth=3,320 mMeasuredHeight=3,455 mPaddingBottom=1,0 mPaddingLeft=1,0 mPaddingRight=1,0 mPaddingTop=1,0 mLeft=1,0 mID=5,NO_ID mPrivateFlags=4,3248 mRight=3,320 mScrollX=1,0 mScrollY=1,0 mBottom=3,455 mTop=1,0 mUserPaddingBottom=1,0 mUserPaddingRight=1,0 mViewFlags=9,402653312 getBaseline()=2,-1 getHeight()=3,455 layout_height=11,FILL_PARENT layout_width=11,FILL_PARENT getTag()=4,null getVisibility()=7,VISIBLE getWidth()=3,320 hasFocus()=4,true isClickable()=5,false isDrawingCacheEnabled()=5,false isEnabled()=4,true isFocusable()=5,false isFocusableInTouchMode()=5,false isFocused()=5,false isHapticFeedbackEnabled()=4,true isInTouchMode()=4,true isSelected()=5,false isSoundEffectsEnabled()=4,true willNotCacheDrawing()=5,false willNotDraw()=4,true ... DONE. The format is simple. Each View is defined on a line of text which ends with \n. The indent at the beginning of the line indicates the depth of the child in the hierarchy. For instance, no indent == root, 1 space == child of the root, 2 spaces == child of a child of the root, etc. classn...@id followed by a list of properties. A property has the following format: name=X,data where X is the number of characters in the data. On Thu, Mar 19, 2009 at 9:57 AM, Dianne Hackborn <hack...@android.com> wrote: > You can look at the hierarchyviewer app. Note that this only works on dev > phones for security reasons. > > On Thu, Mar 19, 2009 at 8:43 AM, adil.b <adil.bukh...@gmail.com> wrote: >> >> Hello all, >> Is there any way for an Android application to retrieve some sort >> of Collection object that contains references to all of the GUI >> elements which are currently on the phone's screen? This could be very >> useful for testing purposes and so on. >> >> If I have overlooked a well-known class or library, please let me >> know. >> >> Thanks. >> >> > > > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support. All such questions should be posted on public > forums, where I and others can see and answer them. > > > > > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---