For example, if I want to know when Youtube is opened, is there any broadcast associated with it? I know of course I can poll the logcat message to check the activity. But can I do it through broadcast since it will be much less power-hungry.
This link seems to indicate it is impossible:<
How to Track App Usage in Android? How to detect when an activity is launched?
In adroid, is there any broadcast when some app is opend?
No, for obvious privacy reasons.
Related
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.
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.
Could someone please help me figurate how to make an app that has no icon and starts at the startup?
I want it to start in every startup and keep running all the time, because I want to Toast the name of the sender each time there's an incoming SMS.
I'm not sure what you mean by "hidden" as the O/S generally tries to avoid allowing you to hide behavior from the user. What you want to do is discussed in this question Trying to start a service on boot on Android. That will enable you to launch a service and then by watching for the appropriate intents related to SMS messages you can create the toasts you desire.
I am making an android program that needs to do something when I receive a message from the Skype app. My Skype will be logged in, and it will be a service or activity waiting for someone to message me, and when it does it will play a song. Does anyone know how, code-wise, I can tell if I have received a message from the Skype app?
If there is no way to do this, how can I have a service scan the notification bar for a notification that contains the text "skype" and react right when it's received?
Thanks for any help.
If skype broadcasts intent upon message reception ( look into decumentation of skype if there is one ) you may just receive it ( via broadcast receiver ) in your application and do something. Incase it does not, there may be still workauround to snoop into status bar:
Detect a new Android notification
for skype notifications
In general "no". There's no way to do that on non-modified system.
You cant intervene other app's events and/or processing directly. It is only possible if Skype itself has provided an open interface (like Service Binding, Broadcast, etc.) to allow third-party integration. But as per my knowledge, I don't think its possible with Skype's own app.
However, if you use Skype's SDK and offer your own implementation of messenger service, then of course you'll be the in-charge.
According to this post in the Skype Developer Forum, the app does not send broadcast events (which would be the usual way to be programmatically notified of incoming messages).
I want to receive Broad Cast receiver for "when will i remove or uninstall my application in device,How to implement,
Thanks
there is no such broadcast. you are not notified when your application is removed
See my answer to [Android] Hook some regular tasks ?.
You can be notified when an app is removed (including your own), but you cannot prevent it or alter the outcome, so depending on what you want to do with the notification, it may not be of any practical use for you.
Also, since your app is being removed asynchronously, your window of opportunity to receive the notification may be too small to do anything practical or respond in any way.
You can use "android.intent.action.PACKAGE_REMOVED" to broadcast the application package that has been removed.