Using Hierarchy Viewer for Android App Widget - android

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 .

Related

how to create Floating window in android

I saw some android applications that has floating window like something in windows OS (or like picture below).I had searched but i could not find any thing.Is any api or library needed or this is just styling?
You can build App Widgets. App Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic update
go to link for more details
https://developer.android.com/guide/topics/appwidgets/index.html
http://www.vogella.com/tutorials/AndroidWidgets/article.html

Espresso android automation tests - How to Access views of other application, opened by my application?

I have a button in my app, that when clicked - opens dropbox login page on chrome.
I'm trying to access the views in that opened chrome window to fill the fields and continue, but because that activity doesn't belong to my application, the views are not in the hierarchy tree.
Anyone knows how to access external application views with espresso?
I already tried with "UI-automator" and "espresso-web", but to no avail.
Android supports multiple windows. Normally, this is transparent (pun intended) to the users and the app developer, yet in certain cases multiple windows are visible (e.g. an auto-complete window gets drawn over the main application window in the search widget). To simplify your life, by default Espresso uses a heuristic to guess which Window you intend to interact with. This heuristic is almost always “good enough”; however, in rare cases, you’ll need to specify which window an interaction should target. You can do this by providing your own root window (aka Root) matcher: e.g. if you want to click on a pop-up which has "OK" and "Cancel" you can use Espresso like following.
onView(withText("OK")).inRoot(withDecorView(not(is(getActivity().getWindow().getDecorView())))).perform(click());
Another example is to use Espresso Intents: For example: User action that results in an external "phone" activity being launched as Clicked on the call button from your own app and you can verify using:
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
user.clickOnView(system.getView(R.id.callButton));
intended(toPackage("com.android.phone"));
Take a look at different examples mentioned on:
Official Google Android Test Forum

Android: How to access display (Activity) of different app that is not shown in upper layer

Hello Android developers,
Im more or less expierenced in Android programming and now i want to create an app that is allowed to access the display of another app or the activity that is less my app. Both apps should be active, should run. My app shall access the display data of the other app (also can be android system display), change it a bit and then show it again.
Is it possible without root rights?
Is there any Android support class that could help me? Which way i can go?
I hope my problem is clear and you can help me!
Ok now I have a more detailed question: How can open my app and show a transparent RelativeLayout, so that you can see what is below my app?
Thankyou a lot
Martin
If both applications are yours, you can access the other Activity using a connection between them (sockets, pipes, shared files, etc.)
If you'd like to create an overlay and display something on top of the other app, you can do that using a 'system window' popup. For example: Popup window in any app
If the other app is an arbitrary software without any modifications, such thing is not possible as it would lead to security issues. Both applications are Unix processes running in their own sandboxes without any direct communication.

How do I run another Android application/activity in a window inside my app

What I want to do is be able to start another Android sub application (which I have not written myself) to run inside a window within my main application. I would want certain touch events etc on the elements of the main app that are still visible to allow me to stop the sub application.
I've found examples of how to launch another activity using an Intent - but I have found nothing allowing me to specify that it runs in a certain window.
Is this possible at all?
The window metaphor does not exist under normal Android.
Some tablet makers have added it to their builds, but using windows would reduce the portability of your app.

How the Activity related to Window in Android?

In Android, the concept Window seems not important anymore.
Until recently devices running Android have generally had small displays that would not be able to present multiple "windows" in a usable way. Android best supports display of a single "window" covering the entire screen at any time - along with dialogs for convenience. That window is typically managed by the system at the command of an Activity. So yes .. in general you should forget about windows and use Activities to manage the UI.

Categories

Resources