I know the android broadcasts an Intent to start an activity. I can use a Broadcast Receiver to receive that intent. But what is the actual way of receiving an intent if an app starts in Android as I don't know what can be the actual intent for an app be (Means I can get the list of installed android applications but how to know what intent will be broadcasted if a particular app starts) .
EDIT :
I'm just adding this as a feature in my phone that if a game launches, then the Immersive mode will automatically be opened. I've system priveleges as well (as I can make the changes in SystemUI or frameworks as well). I don't want to touch the Launcher though.
by this way . But it's still a little bit weird as solution . I don't think there's any simple way to do it...
Related
I would like to know how do I make an application that is running in the background open automatically when I have some event.
Android Manifest allows you to set up filters that act much like a listener to start an Activity. startActivity(intent); allows you to fire an event that starts the Activity. Not quite sure of specific way to do this in your code unless you share the code if packages are different you may need pending intent to get around permissions. Are you lanching Service or activity?
I have an app that keeps the screen off when calling via bluetooth. It's a long story but for more context please visit http://www.rejh.nl/callscreenoff (not trying to spam, it's just to avoid the "why would you build an app for that?!" question)
Anyway. I have a problem. Everything works fine except that my Moto X turns on the screen a couple of (variable) seconds AFTER I hang up which makes it hard to determine if my app should lock the device (it could be the user who, after the call, immediately pulls his phone out of his pocket and wants to unlock it).
What I'm looking for is a way to detect which app caused the screen to turn on. Since I'm using a broadcastreceiver to detect USER_PRESENT and SCREEN_ON it would be nice if I could get this info in the receiver. Is there some data in the intent I receive about way I can find out which app caused the intent to fire screen to wake up?
Thanks in advance!
According to this answer it is not possible. The intent sender could put extras in the intent, which would give away the indentity of him, so your best bet would be either catching the intent in the debugger and inspecting the extras, or using an app for that, for example: Android Intent Intercept
I have a device management application, which essentially runs as a service in the background from boot. I'd like to start this application immediately after installation. How do I achieve this?
You cannot do this -- there is no way to automatically start your service merely because it was installed.
The application must first be invoked by the user through some sort of activity. Or, you are going to need to hook into some relevant broadcast Intent via the manifest, so you can get control when one of those events occur and kick off your service that way. Or, you are going to need to ask the user to reboot so your BOOT_COMPLETED Intent filter can get control.
There was a hole - the Android Analytics SDK used to send an intent right after installation - but that got closed (producing lots of confusion, of course).
But the final answer, I believe, is here:
http://developer.android.com/about/versions/android-3.1.html#launchcontrols
This seems to suggest that, as of 3.1, Google made the decision that apps are in a stopped state until the user explicitly activates them, e.g. by launching app or placing widget.
This means that the strategy of listening of a common broadcast (i.e. to get your app launched surreptitiously) won't work either.
How to start an application that has no launcher activity?
Story behind the problem:
I have an application that is basically a BroadcastReceiver that waits for a couple system intents like BOOT_COMPLETED. The problem is that as my application has no Activity, it doesn't get started and so it receives no intent.
Android 3.1 release notes mention that intent options can be overridden to start up applications but I assume it requires another active application to do so.
P.S. Write all the ways you know. ADB commands as well.
First piece of advice would be to make a very simple "Welcome to my App" Activity that could be run. Use it to show a splash screen, some advertising, or be a settings screen. That gets you around the "no Activity" problem.
As far as I know, you cannot have anything hooking into BOOT_COMPLETED until and Activity in your application has been run. So you need to have an Activity of some sort.
I have a device management application, which essentially runs as a service in the background from boot. I'd like to start this application immediately after installation. How do I achieve this?
You cannot do this -- there is no way to automatically start your service merely because it was installed.
The application must first be invoked by the user through some sort of activity. Or, you are going to need to hook into some relevant broadcast Intent via the manifest, so you can get control when one of those events occur and kick off your service that way. Or, you are going to need to ask the user to reboot so your BOOT_COMPLETED Intent filter can get control.
There was a hole - the Android Analytics SDK used to send an intent right after installation - but that got closed (producing lots of confusion, of course).
But the final answer, I believe, is here:
http://developer.android.com/about/versions/android-3.1.html#launchcontrols
This seems to suggest that, as of 3.1, Google made the decision that apps are in a stopped state until the user explicitly activates them, e.g. by launching app or placing widget.
This means that the strategy of listening of a common broadcast (i.e. to get your app launched surreptitiously) won't work either.