How to check if certain intent has started - android

How to check if intent or app has started ?
My use case is I am showing up notifications through my app and I want to clear them all via myBuilder.cancelAll() if default messaging app has started since my app shows sms notifications. So I am kind of looking for something like:
if (smsAppStarted) {
myBuilder.cancelAll();
}
Thanks

To check if an app has started:
Get the package name of the sms app you want to check.
Then refer to my answer here:
Android how to know an app has been started and range apps priority according the starting times
By using that code, the list taskInfo will contain the list of all apps currently running. Search that list using the package name of the sms app. If it is present in that list, it means that that app has started and currently running.

If I get you right, you need to determine, if another app is currently running. If so, then use this solution.

Related

Detect application is being uninstalled in lollipop devices

I would like to know which users have uninstalled my application so that I can ask them for a feedback to improve the app. Hence, I would like to detect when the user has initiated the uninstallation process on my app.
One of the older solutions on StackOverflow had the following steps:
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(MAX_PRIORITY);
String activityName = taskInfo.get(0).topActivity.getClassName();
if (activityName.equals("com.android.packageinstaller.UninstallerActivity")) {
// do whatever is needed
Since Lollipop, getRunningTasks has been deprecated. So how can com.android.packageinstaller.UninstallerActivity activity be detected without getRunningTask?
Alternatively is there any other method to detect uninstallation process has been started on my app? Using getAppTask probably?
Apparently you wont be able to do this, you will have to rely on something called silent notification.
What we did was we sent notification every 3 days or whatever frequency you want.
On the client side as soon as a notification is received we hit a network call which mark NotificationReceived for the client. Now since notification are not full proof we assumed a threshold of 2/3 missed notification as uninstall event. And for the client we have this counter above decided threshold we contacted them for feedback.
Also no one will be willing to fill your form at the time of uninstallation as user has already decided to uninstall your application.
Read these 2 questions and answers:
native solution
GCM solution
As I know you have to mix the two. Read the limitations of first solution. You have to confirm uninstallation event of the first solution with the second solution for a complete implementation.
Hopefully, this solution will work for you. It helps you understand the reasons for your app uninstalls, reduce the uninstall rate using a powerful predictive engine and also get app Re-installs through a unique actionable channel (Android version 4.0 and above).
Just set a variable named appLastPresent for every user in the server-side and update that variable every day by calling an API using WorkManager's PeriodicWorkRequest. Also set installedDate variable when the user installs the app.
Now set up a chron job on the server side to check if the difference between installedDate and appLastPresent is greater than 7 days. Then send the user an email or message enquiring for issues or feedback, if it is greater.
NB: User can be offline for 7 days. Therefore only send email enquiring like why you are not using the app, if uninstalled please let us know why

How can I Detect an favorite android app started?

I want to implement an app which can detect what app launched, to do something with that!
for example I have a list of installed applications in my app and mark one favorite app. and when I start that marked app from default launcher or anyway, I could detect it and do something with that by a background service or broadcast receiver(For example launch a toast message).
How can I do this?
this isnt possible.. to be able to monitor all intents would make android extremely insecure
http://groups.google.com/group/andro...ddc9d36a24d77b
but there are ways to know when an application is launched. you just have to be creative.
this will give you a list of all the applications running.
Code:
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();
however to know when an app is launched you would need a timed loop and then check between versions of the List to see if there is a new app. this would suck the juice and be inneficient
AppProtector seem to access the eventlog. maybe you could have a ContentObserver attached to the event log
http://developer.android.com/referen.../EventLog.html
http://developer.android.com/referen...tObserver.html
EDIT
Interesting.
I also found this which solve your problem.
When you open any app from launcher below code will return the info of opened app so now you need to compare a package name with your favourite app package name which you already stored in your app database.
Code:
String str = ((ActivityManager.RunningTaskInfo)this.am.getRunningTasks(1).get(0)).topActivity.getPackageName();

Start Android application from NFC-tag with extra data

I can start my application by simply putting the phone on a NFC-tag. But I would like to take the idea one step further. Imagine a simple time-tracking application with two NFC-tags. The first will start (and download) the application and register a starttime. The other will also start (and download) the application, but register a stoptime.
My problem I'd like to solve is that I don't want my phone to know about these tags. The application should not need to have a list of tag-ids programmed and know what actions that is connected to each id. The tag should carry the information needed to start the action on the phone with the correct parameters.
Are there any information about how to accomplish this scenario? I have installed "nfc-eclipse-plugin" but doesn't understand how to use it to get my goal and even less how to get my application to read the extra data.
Thanks in advance
Roland
Your tags should be capable of storing NDEF messages. Such messages are automatically read out by Android and passed to your app in an Intent. Automatically installing and/or starting your app can be accomplished by putting an Android Application Record in your tag. Any additional information ("start" or "stop" indication) can be stored in a proprietary record.
You probably want to put the AAR as the last record of the NDEF message, as it is detected and acted upon by Android automatically, but is only supported since ICS. To make automatic installation work with Gingerbread, you can put an additional URI record or SmartPoster record with a Google Play Store link in it as the first record of the message. Your app should then filter (ACTION_NDEF_DISCOVERED) for this URI, so it will also start automatically on Gingerbread.

How do you get an Android app to automatically run after download and installation?

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.

Intent resolution in Android

If I want to create custom address book (which overrides my phone's default address book), and if I want it to be used by all applications, what should be my intent-filter? Does Android allow me to do such a thing considering the fact that such a third-party app could potentially be malicious?!
And, if I want to have yet another address book application, I suppose the second app also has same intent-filter, isn't it? How does the framework decide which app to pick if I click on Contacts button when making a call? In other words, how does the framework resolve intents in case,there is a conflict between multiple intent-filters?
You can replace any application on Android platform, even Home. Android documentation explains everything there is to know about Intents and Intent Filters and there is a section called Intent Resolution that answers your question. Intent Resolution section for Intent class has some additional information.
As far as I can tell Android doesn't try to resolve a conflict. It ask the user which application to run and gives them the choice to mark this Activity as the default for this Intent. They give an example about mail app here.
While Mr. Smiljanić is basically correct, there is no Contacts application in Android for you to replace. There is Dialtacts, which is the application supporting the contacts, call log, and dialer. That application cannot be replaced, mostly because the dialer cannot be replaced.
So, while you may be able to override some intent filters and get control on some contacts-related requests, you will be unable to get the contacts portion of Dialtacts overridden, which will confuse users.

Categories

Resources