Android UI Automation: Subscribe to Android Events - android

Is there a way to subscribe to events from an installed app on a AVD? What I would like to do is, e.g., when I enter any text on a EditText field in the app, I want to automatically receive a notification in my program, with the details (entered value). Is there any way I can subscribe to the android app events from any installed apk ? If there are frameworks or any Android native drivers which can do this, please mention them.

It looks like you might be able to do something similar via Android's accessibility API. You'd need to write an Accessibility Service which would need to be installed and then explicitly enabled via the control panel (this is a security precaution to prevent arbitrary apps getting access to potentially sensitive contents of UI of other apps). Your service can listen to AccessibilityEvents - looks like TYPE_VIEW_TEXT_CHANGED event - "Represents the event of changing the text of an EditText" - is the one you want.

What you need is Google Analytics for Android

Related

Is there a way to get informed about what app is in the front in runtime in Android?

For my app I need to generate a list of the applications that the user has used in a period.
Is it possible to receive an event every time an app happens to be in the front?
What permissions are needed? Can be received by normal apps or only by system apps?
I think you can use permission "android.permission.BIND_ACCESSIBILITY_SERVICE" and then get the windows by using List getWindows ();
Read more about it here: https://developer.android.com/guide/topics/ui/accessibility/services.html
Users have to access the service manually, and are warned when activated.
Activation looks something like this

Can you send click events to another application?

I'm trying to send click events from one application (or service) to another application while it's in the background.
I've learned about the ability to send Intents to other applications. I was able to send an id, that represented a view id inside the receiving android application, and have the receiving application handle the click event. But I'm trying to accomplish this with a receiving application that I have no control of (can't setup intent filters, etc). I understand the security risks with this, but I'm just trying to achieve it for a quick demo, not an actual application.
Is this possible? Maybe on a rooted device?
There are automated Android testing frameworks which allow you to test both white-box within your own code, as well as black-box on other applications. Unfortunately I haven't gotten the chance to try automated testing on an outside app, but presumably you would be able to simulate click events in the same way that you can within your own application.
Perhaps this would be something to look into?
http://robotium.googlecode.com/svn-history/r376/doc/com/jayway/android/robotium/solo/Solo.html#clickOnView(android.view.View)

Android service to monitor click events

I've just started getting into Android development and as a proof of concept I am tasked with creating a click logging system for several applications. These applications may be written by other teams within my organization or may very well be any application downloaded from Google Play.
So is it possible to create a service that monitors every click event from any application running? Any type of global onClick Listener?
If so, any pointers in the right direction would be helpful, thanks.
You can try adding a transparent view to the global window manager, same place toast messages are added. Then you can just intercept touch events via by overriding the onInterceptTouchEvent() method on any viewGroup and passing the event down.
Many apps have a similar approach (AnyDo is one of the apps that add a view in this manner, Facebook Home as well).
So is it possible to create a service that monitors every click event from any application running? Any type of global onClick Listener?
Fortunately, not on Android 4.0+, for obvious privacy and security reasons. Such a "tapjacking" attack was possible on earlier versions of Android.

Intercepting Android Notifications based on associated audio file?

Basically what the title is saying. I'm trying to make a small app that can determine what audio file was just played for a notification, and react based on that. Is there a way to monitor all incoming notifications on android to get this effect?
I ended up going with the "Accessibility Service" as a way to read all incoming system notifications, and then handled them appropriately depending on what type of even was happening. I discovered that this is also how applications like Tasker handle similar functionality.
More information is available here:
http://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html
No, the stream of notifications is not available to applications. (It would be a security hole, allowing any installed app to read your email, for example.)

Control over app activities in android

As far as I know, there is no way to control over the activities occurring in an app in android phones unless the application that you want to log/monitor is written by you.
I wonder is it really like that or is there any possible way to do this? For example, is it possible to control over emails which, let's say, who I sent an email to in an android phone?
It is not possible to "just log it". Some events are possible to catch in broadcast receivers in a logging application. The user will get notified by particular event sniffing when installing such an application, by approving the permissions request.
It's generally possible to add instrumentation for security purposes to apps where they interface to the sdk api's, either by modifying the platform (rooted phone) or by decompiling, modifying, and recompiling the app using apktool.
possible of course does not mean trivially easy.

Categories

Resources