Detecting which applications send taps to or view my application - android

Are there ways to detect which packages send taps to my own application or are viewing the screen of my application?
I checked MotionEvent but it does not provide a way to get the package name that sends taps. I am not too sure about detecting applications that are looking at my application's activity etc.

Related

How to recognize when user has input information in an android app?

For example, the user is inputting information about himself in application A, and he returns to the home UI before he finished inputting. How do I recognize a situation described above in application A.
Can I add some code in android source code?
Using onUserInteraction(), user interaction with app can be found. For deUser Interaction with App
And for detecting user is on dektop, define a background service and detect the package name. Somelike is done by lock app.

detect button click globally

In android, is there anyway to detect that a foreground app's button is clicked? I am not talking about my own app, I mean detect globally a button press event.
For exapmle, skype is running in foreground, I'd like to detect when user clicked a button in skype.
=====UPDATE=====
If the answer of above question is no, is there a way to detect window focus change OR dialog popup globally?
the answer is no and no.
That is by design and it's a "security feature". Android is sandboxed, apps operate on separate Windows and separate processes and are not supposed to know about each other. Unless the specific app is broadcasting something, there's no way to external apps to access it.
Try to imagine what a HUGE security flaw that would be to have that type of access.
malicious code is installed with permission to receive "global clicks" and "draw on top of other apps".
user installs banking app
user click on login on banking app
malicious code receive the click and draw on top of the app something that looks exactly like the banking app
user type his/her login details
malicious code transmit user details to remote server
developer of malicious code withdraw users money.
to conclude: I'm very happy that Android does not provide such functionality.

Launch my Activity when any (or selected) Apps are launched

I'm developing a Learning Application. In it, I have an Activity where the user can select some applications from a list of all the applications installed on his device.
Now, I'd like to launch my Activity whenever the user launches any of the selected applications from the app list. Basically I'd like to override the selected Activity by my activity. Once the user complete's some task, the user should be returned to the previously clicked Application.
How do I "Capture" this 'Launching other applications' part? BroadcastReceivers? Any example would be highly helpful. I'd be very grateful if anyone points me in the right direction with reference links.
This is very similar to a Lock Apps Application. But in a very badly twisted kind of way.
I know I have to use a background service to monitor the user activity.
You don't intercept arbitrary application launches, if that's what you're after. Doing this silently goes against the Android (or any reasonable) security model.
What you can do is offer an alternative Home screen.
However, if you just have a list view of available applications, nothing stops you from defining custom behaviours within that list activity.

Android Intercepting Events From Other Apps

Does anyone knows how to intercept events from other 3rd party Apps, say, games, Maps, etc.
This includes events like motionevents, screen prompts, etc.
We have limited success with capturing touch events via the AccessibilityService, click, longclick, etc. But hitting a blank dealing with motionevents such as gestures or how the users are interacting with the screen.
(we have approval from users to capture such information in a control study)
We believe that if we root the phone (mess with the kernel) we can get such data but this inadvertently void the warranty on the user phone, so is there any other way to obtain such information on the API level?
Many thanks!
In case you are talking about your application gathering information about other applications life time interaction with the user then definitely no.
If this would be possible you could easily write a key logger and steal someones private data.

How to detect launch of an app in Android from a background service or another app

I want to create an app or background service that just listens for the launch of a 'default' app, say Contacts or the built-in Gmail app. If the contact app is clicked, I want to transfer control to my app temporarily (e.g. present a Yes/No popup to the user or increment an internal counter of my app ) and then redirect the user back to the app that was clicked. I want to do this only for a couple of 'well-known' built-in default apps, not any third party apps.
Is this possible? May be using some special intents?
Have you tried registering broadcast receivers for the intents that would launch those built-in apps? This might not work since that might confuse Android into thinking your app is a potential target for those intents (e.g. that it should be used to actually write and send the email in the case of a 'compose an email' intent), but it should be a good place to start.

Categories

Resources