1 . can we get any event when user tap/touch native application(i.e. messaging,contacts).
2 . i know that any application launch by intent in android, there is any way to know which application launch with launch of application.
Thanks
No, We can not get any event directly or by any receiver.
what I have figured it that it can not be done directly......
But there are two work around for this :
Start a service that will check top-activity always by this way can know what activity got launched and do whatever you do under this condition.
Catch the logcat, read the line, and you can easily get what event what even took place, and by using your required filters you can even do whatever you like :)
can we get any event when user
tap/touch native application(i.e.
messaging,contacts).
Not generally. Most of these icons are tied to their applications.
there is any way to know which application launch with launch of application.
This makes no sense to me, sorry.
I am agree with #K_Rapid's answer..
Check code of AppLocker
I hope you will got solution from that code...
For (1): what do you mean by 'tap/touch'? Do you mean when the built-in applications are launched, or when they're interacted with?
If you mean launching, you can listen to any intents being fired by the system by registering a broadcast receiver. If you set your IntentFilter to receive intents with CATEGORY_LAUNCHER, you should be able to see when the launcher starts applications.
See:
http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LAUNCHER
http://developer.android.com/reference/android/content/BroadcastReceiver.html
If you mean interacting, I don't think you can do that.
For (2): I don't believe that intents remember where they were constructed, so I don't think this is possible. I could be wrong, however.
Related
Thanks in advanced, I am using imsdroid library in my app. calling feature work fine, but i am unable to receive call when app is closed.When I minimize application it works but when i clear application from recent app it can't receive call. What is solution for this issue, please help me out. or provide some reference links.
According to me, IMSdroid does not provide this functionality. You have to open your application while dealing with them. I got same issue:
https://code.google.com/p/imsdroid/issues/detail?can=2&q=491&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&id=491
finally resolved it with some customization.
#nik u r right. it is not possible to keep registered all the time.in that case u have to notify the second person when first client tries to make him a call ,and when second client will get notification, then fire a broadcast to start the NativeService. this will register the device. and finally u will get the incoming call.
Suppose there are two apps on my device, GoodApp and EvilApp. I didn't write either of them. Both apps can use an ACTION_SEND Intent to start an exported activity in my app, passing data in. They both call startActivity, not startActivityForResult.
I want to trust the data I receive from GoodApp, but distrust and ignore the data I receive from EvilApp.
How can my Activity tell which app started it? Activity.getCallingActivity() returns null, because it wasn't started for-result. I can't send a message back to the apps asking "was it you who sent me this?" because they aren't written to respond to that, and their code is out of my control. Is there any way I can tell the difference?
Require apps use startActivityForResult in order for you to handle their request? (:
ActivityManager.getRunningTasks might give you a hint, but its documentation says not to use it for things like what you are asking.
I want to use this broadcast intent to start my activity as soon as my mobile enters NFC reader's field? Please help if anybody ever done this....
It is possible but not recommended to do this.
First off, the ACTION_RF_FIELD_ON_DETECTED is a protected intent. To be able to receive it you have to white-list your application in the etc/nfcee_access.xml file. This file grants access to the secure element, so it is not writable on non rooted phones.
Second: The ACTION_RF_FIELD_ON_DETECTED event is not reliable. This is stated in the source-code and true in praxis. You simply don't get such the intent every time the phone senses an RF field (has technical/historical reasons that I won't explain here in detail).
If you can work around these two problems, you can just list ACTION_RF_FIELD_ON_DETECTED in your manifest and Android will happily start your application.
I'm looking at the description for the Plan B app here: https://play.google.com/store/apps/details?id=com.lookout.labs.planb. It says it will start automatically after installation. How do you configure an app to do this?
Register to receive common intents. One especially suitable for your purpose is:
"android.intent.action.PACKAGE_ADDED"
You might also listen for other intents such as BOOT_COMPLETED, etc.
Edit: According to another Stack Overflow answer, You can't run your own application immediately after it's installed. You must register for other intents as I suggested. Something to note is that you app will require user permission to receive the BOOT_COMPLETED intent.
Update: As pointed out by zapl, post 4.0 you cannot do anything after install now until the user explicitly launches your app.
is it possible somehow to listen to the events of the ActivityManager, e.g. when activities are started? Does the ActivityManager send broadcasts? I havn't found anything indicating that it does.
What I basically need to do: I want my app to launch one of my activities whenever a certain (thirdparty) app is launched/takes focus. Problem is this needs to happen before the thirdparty app is actually displayed.
What I have tried so far as workarounds:
Logcat output: I query logcat every 0.8s (filtered to show ActivityManager events only) but this eats up to many ressources
getRunningTasks: Slows down the phone a lot too and is not very safe, as an activity might be running but not currently in focus
Any ideas?
I suppose there is no actually other legacy way to handle glabal system state, only
(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.getRecentTasks() - Return a list of the tasks that are currently running, with the most recent being first and older ones after in order.
For details check docs
Perhaps though Android is a Linux you can run system tools like
Runtime.getRuntime().exec("ps -aux | grep smth")
But I think it would be hard to detect particular java application.
I think you can use the launch mode to determine which activity to launch to top level. Please check the question: Android singleTask or singleInstance launch mode?. Maybe it will help you.
I had a look in the android source, but there doesn't seem to be any events broadcasted.
https://android.googlesource.com/platform/packages/providers/ApplicationsProvider