I have very complex layout xml (1K+ code rows). When I perform under testing some input (touch, click, swipe...) I want to know what happens: Which elements under focus, which elements got click events etc.
I tried under developer options to enable show layout bounds & show touches. But it's not what I'm looking for. Also I want to avoid solution of Log prints on entry to View methods, Because I think must be a more direct method.
EDIT - This app dev environment is still Eclipse.
Thanks,
Try the Hierarchy Viewer of the Android Studio Tools. It work fine for your purpose.
If you are using the Android SDK in any other way, you can see here that you can find the same Hierarchy Viewer from the SDK tools/ directory, entering to monitor.
Related
I'm facing a problem in Android GUI testing. When using the UIAutomator to get all the elements in a certain GUI, I can not determine whether I can input some contents in an element, or swipe it left or right.
I'm wondering if there is a way like Chrome Dev Tools that assists in finding all the binding events for a certain element in an Android app? Many thanks.
Is it possible to use Hierarchy Viewer for App Widget?
If yes, how? and is there any Tutorial for that?
Have you tried using Hierarchy Viewer for UI elemements? I followed these instructions yesterday and they worked fine for me.
To run Hierarchy Viewer, you can follow these steps:
Connect your device or launch an emulator.
To preserve security, Hierarchy Viewer can only connect to devices running a developer version of the Android system.
If you have not done so already, install the application you want to work with.
Run the application, and ensure that its UI is visible.
From a terminal (command prompt), launch hierarchyviewer from the /tools/ directory.
The first window you see displays a list of devices and emulators. To expand the list of Activity objects for a device or emulator, click the arrow on the left. This displays a list of the Activity objects whose UI is currently visible on the device or emulator. The objects are listed by their Android component name. The list includes both your application Activity and system Activity objects. A screenshot of this window appears in figure 1.
Select the name of your Activity from the list. You can now look at its view hierarchy using the View Hierarchy window, or look at a magnified image of the UI using the Pixel Perfect window.
Since this will not work on a stock Android system you must use either a developer version or an emulator.
Please! check here
Please let me know if these instructions don't work for app widgets or if you have more questions.
Now Hierarchy Viewer is deprecated, you should use Layout Inspector. I follow next steps:
launch my app with widget on emulator
click Tools/Layout Inspector
Set check box Show all processes
Next you should choose the process. Android app widget code executes
in OS launcher process, so you need choose it in Choose Process
menu. For me it calls com.android.launcher3
After all you get layout with your app widget
I think this steps don't work with real device, because system process doesn't available for debugging
This was the correct answer until Romain Guy developed a workaround.
You can now add the ViewServer class to your project, and use HierarchyView in any device.
The code needed is available here:
https://github.com/romainguy/ViewServer
For more info check this .
I am new to android technology, while developing application i need to debug the UI component like why this textview is not displayed or so.
Like we have Log facility for the java code, do we have similar kind of thing for xml also.
so that we can verify which layout is overlapping with another or find out other distortion in UI
Thanks for your time.
In Eclipse, there is a helpful tool to see your UI hierarchy. When in debug mode, open the "Devices" window (if you can't find it: Alt+Shift+Q, Q). Then click the "Dump View Hierarchy for UI Automator".
You can see some view attributes there as well as the way it's build up.
There's also a hierarchy viewer in the SDK tools/ directory, but I haven't used it yet.
It does have one. A very basic one. The problem is, the 'debugger' doesn't know what you want. Your TextView doesn't display is a problem for you because you want it to display. But the debugger though you left the code like this simply because you will programmatically add the text during run time. So debugger for UI wouldn't solve these kind of problems , but it will give you tips and warnings like this :
I need a way to show off concept designs of an android application on an android phone to simulate that it is running. Basically just being able to tap to advance to the next photo/screen would be sufficient with a tap ANYWHERE on the screen. Any tools you know that would be helpful?
Eclipse with Android toolkit.
Write a small program. wont take up much time.
[update]
No coding is required. Create an android project Using Eclipse android project, you can visually create UI prototype (i.e. drag and drop .. no coding). Use main.xml after developing each screen run the project in emulator, you can take screenshot of the same (either using eclipse DDMS plugin's snapshot capability or using Alt+Print screen in windows or something similar in other OS). Use this screenshot in a powerpoint presetation . Repeat the same process for a second screen (overwrite the same main.xml so that you dont have to write code). take screenshot again. Add the required animations in powerpoint.
Is there any other option that does not involve any code?
The easiest way I can think of is:
1. Take screen shots(wireframes, screen prototypes) for every screen flow you wish to demonstrate.
2. add them in proper sequence(regulated by sequence number) to your sdcard.
3. Open Picture gallery and use swipe gesture to transition and cycle between screen, walk through all the screen flows.
Do it photoshop, create images, add it to an activity. Create a layout that fills the parent, add it as a background. Then implement a ontouch method to finish the activity and load the next. Quite simple.
I want to add the functinality of Home,Back,Searcha and Menu Hard keys via some soft keys which can be accessed anytime the device is up.
I know their are few applications available which already do this, but i wanted to know the way this can be implemented.
Any help would be appreciated.
As stated elsewhere, the SDK is not enough to emulate hardware buttons: you need to be able to modify or at least call system sources, so you should be compiling Android from sources.
That said you can emulate the software button by calling "injectKeyEvent" in IWindowManager like done in these examples:
http://java-admin.iteye.com/blog/813208 (chinese)
http://tinyurl.com/5spjxja (android-x86 patch)