detect button click globally - android

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.

Related

How to detect when user returns to app specifically via "Recent apps"?

I have my own pin code activity in my app which popup every time user returns to the app (on first start or when the app was in background). I found it curious that some bank apps can somehow detect when user just jumped to another app via "Recent app" and then return to the bank app (in this case PIN activity will not show up in these apps). How did they do it that when returned from Recent Apps, pin code activity will not be triggered?
I tried androidX´s LifecycleObserve and ComponentCallbacks2.
Currently I´m using registerActivityLifecycleCallbacks to generally detect when user leaves the app, but I have not idea, how to programmatically differentiate these two cases? Any ideas?
I have my own pin code activity in my app which popup every time user returns to the app (on first start or when the app was in background). I found it curious that some bank apps can somehow detect when user just jumped to another app via "Recent app" and then return to the bank app (in this case PIN activity will not show up in these apps).
What makes you so sure they're detecting that you came back from "recent apps"? If you go to a bank app, press back to close the app, then re-launch it from the list of apps, you may not be prompted for a pin or password.
If you leave the app for long enough and come back to it from "recent apps", you may be prompted for a pin or password.
More than likely these apps are employing some kind of time-based heuristic, although this will of course vary by app.
How did they do it that when returned from Recent Apps, pin code activity will not be triggered?
I don't know how "they did it", but as for the the question of "how can I know my activity was launched from recents"? Try looking for FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY in your intent.
Hope that helps!

Possible to detect page visits

Is it possible to somehow detect when a user goes to a page from within an service (or broadcast receiver) ? I would like to add a feature on my app which detects whenever the user goes to mysite.com, and show an alertdialog asking if the user wants to launch the app for a more convenient experience.
add: i should add that my app is used to browse data from mysite.com much easier.

Prevent Android application from starting

I have read many question about whether it is possible to prevent an Android application from starting, but all of the answers seem to be "no, you cannot".
The idea is very simple: we want the user to be able to use a restrited set of applications that will be preinstalled on his mobile device. If the user tries to start a non authorized application, he will be prompted with a dialog asking for a PIN. If he enters the right PIN, then he will be able to run the application. Otherwise, the application will not be run.
As I said before, all the answers that I could find out there fall into two categories: "you can't do that" and "you can do that by writting your own launcher application".
However, I have seen applications such as ZDBox, which allow you to do just that. That is, with ZDBox you can define "non authorized" apps, in such a way that if the user tries to start one of them, he will need to enter a PIN to actually start the app. If he fails to provide one, the app will not start. The funny thing is that ZDBox does not require root access to do this.
So my question is, how can we prevent other apps from starting, just as ZDBox does?
Option 1
All the examples I've seen involve running your app as a Launcher/Home Screen replacement. This is how all the child lock style apps I've used work. This has the advantage
Pressing Home button doesn't leave the app
You have control of app launching
You can check out the android Launcher2 code to see how the Android launcher works. https://android.googlesource.com/platform/packages/apps/Launcher2.git
Option 2
There does look to be one alternative that I can see. In that you can try and read the logcat entries to detect when a blacklisted app is launched or brought to foreground and then launch your app over the top.
Similar to how they detect an app launch in How to detect when the user launches another app? (Android)

How to set my app as default home android?

I'm developing a Android application, and I would like that when it first starts it set itself as default action for Home button.
Currently this option is given to the user by the Android system only when he first press the Home button after running my app.
User don't want to click on check box as "Use by default for this action" it should be set by default my apps.
Thanks in advance.
This is not possible, and it is a good thing too.
Android allows users to choose their own defaults to prevent malicious apps from making themselves the default app to deal with an action, and hence protecting the user's data and device. If an app could set itself as the default homescreen or browser or call app etc. then it could steal the user's personal data and also potentially spoil or deny access to the device itself.
Due to the above reasons, this is not possible why the Android SDK, and I sincerely doubt that an unofficial means to do this exists.

Password Protect the Applications Button

How can I password protect the Applications button on my Home of my android phone (samsung galaxy s captivate).
I know there is password protect application out there with a list of application you need to add but I don't want that. I want to protect the whole access of the applications.
I'm pretty sure that blocking access to an application from the Home Screen isn't common practice, actually I think you can't even control this as it's part of the Android OS itself. After all, what's the point in blocking user access at the Home Screen since the user already has to unlock his phone in order to get there... usually trough a password.
A viable option would be to greet your users on a Login Activity and you'd have them identify themselves before they can access the actual Application functionality.
If you really want to start blocking users at the Home Screen, you're probably looking at creating your own ROM and Application. But then, no one will want to re-do their whole OS simply to run your application.
Write your own home screen, one that prevents launching any applications unless the user authenticates.

Categories

Resources