Detect when app is opened with a service - android

I want to be able to detect when an application is opened and notify the user of something at the moment related to that same application but I don't know how to do this.
The user opens my app
I intent the service (background / foreground) and it successfully starts
Whenever the user opens another application I want to "catch it" and present a notification to the user
How can this be made? Are there any event listeners i need to use? Thank you very much.

If you are trying to catch "open app" intents in general, then it depends on how the app defined the intent. If it specified a class (explicit intent) then it will generally not be visible to your app unless the device is rooted, for example.
Implicit intents are broadcast and you simply need to define an intent filter in order to receive them. These are intents that allow Android and/or the user to select the appropriate app target based on data sent with the intent.
There are both useful and malicious motivations to do the kind of thing you are asking about. Read this:
Android Intent Security
And also the posted comment on learning about intents overall.

This is really simple. Here I am trying to figure out the solution. When your app goes on onPause() state then broadcast a message using BroadcastReceiver. On the other hand in another app just register for that broadcast.

Related

Is it possible that one android app sends clicks to another open android app?

I´d like to control an app with another app.
As far as I know apps in background get paused.
Is there any way to send commands/clicks etc to another app by my control app?
Thanks
Not generally. If you wrote both apps, you are welcome to implement your own control IPC mechanism. An accessibility service can do what you want to a limited extent for arbitrary apps, but nobody with any sense will install your accessibility service, given that you can do all sorts of nasty things to the user and so there are security warnings that get raised when the user goes to activate your accessibility service. On rooted devices, there are probably many more options.
If you want to send click events to another App, you can achieve it by Broadcast Receiver.
You have to send a broadcast message and the other app must have a receiver to receive the trigger.
you can get more information about broadcast receiver by this link https://developer.android.com/guide/components/broadcasts.html
What you are looking for is a service. In a bounded service, Inter process communication is extremely easy, read here.
https://developer.android.com/guide/components/bound-services.html
You simply bound both your apps to a service they can talk to eachother.

How to show confirmation message before opening the default messaging application?

I want user to confirm By selecting yes or no that whether he/she is sure to open the message application or not.
This will be similar to CALL CONFIRM android app which confirms when making a call.
I can also manage if someone let me know a thing like broadcast receiver as in the case of making a call.
Like i would be able to confirm when send button is pressed in message application.
This is my first question on this forum. :)
it can be achieved in more than one way,
create a service and monitor activity stack, if activity matches com.android.mms.* you can show your notification to user
create an application with all the intents for launching the messaging application, you can find out all possible intents from stock messaging application's android manifest file for your ref
http://www.netmite.com/android/mydroid/2.0/packages/apps/Mms/AndroidManifest.xml

Using android Intent to launch my application in background

Is it possible to launch two applications with one Intent? For example, broadcast intents fire those who are listening to them.
My idea is to run a watcher while user is browsing websites using android browser. So far, my searches tell me to use intent filter to capture ACTION_VIEW with data "http" or "https". But this isn't what I needed. It will ask users whether they want to use my application to complete action.
Any suggestions would welcome too.
If you want to run something in background, use Service. If you need to have Activity and Service running simultaneously, then start you "watcher" Service in onCreate() and stop it in onDestroy().
You then will need to handle only Activity intent and user will not need to choose anything.

How can one detect an Android application launching?

Is it possible to detect when an app is executed (i.e., when the user clicks on the app's icon)? I attempted to register an intent of type Intent.ACTION_MAIN using a category of of type Intent.CATEGORY_LAUNCHER hoping this would let me know whenever an app is launched. The problem is, my broadcast receiver is never getting called.
Is this an illegal intent/category combination for which to register? Is there some method I can use to determine when an application launch occurs?
The application start Intent is not a broadcast, so there is no way to register a broadcast receiver and receive it. As previously answered here, there really is no way to detect the launch of the app. You could possibly write a service that polled the running tasks looking for the application's task (using the ActivityManager interface), but that's the best I can think of and it probably wouldn't be very performant.
There aren't any broadcast intent when an application is launched for the general case. If the application you want to detect is yours, you can fire your own intent broadcast, but if not, then no, you can't detect it.

Intercept intent to open text messaging?

Suppose a user opens up the default messaging application, scrolls through their text message inbox, and then clicks on a specific person to open up the text messages between them. Is it possible to intercept and act upon the intent fired when they click on that person's name?
To clarify, I don't want to stop other applications from receiving the intent. I suppose intercept was a misleading word. I just want to know if there is some way to detect that the text messaging screen is being opened as well as who it is to.
I strongly believe no. Such capability would pose quite a security risk as "developers" with mischievous intentions could secretly have their app intercepting intents all throughout the device. I would suspect you have to create your own messaging app to accommodate what you have in mind.
I think you're putting to much significance on Intents. That is actually just an action internal to the application. Not everything you click in Android results in an Intent being fired and even if it does, not all intents are broadcast to everybody. In this case, what happens is you touch a list and it opens up another activity, likely via startActivity (which does make use of an Intent but not a broadcast). Additionally, it's not possible to "intercept" Intents. You can act on them, sure, but you can't prevent other applications from seeing them if they are broadcast.

Categories

Resources