Dev01
Dev01

Reputation: 4222

How to check if certain intent has started

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

Upvotes: 0

Views: 304

Answers (2)

a.ch.
a.ch.

Reputation: 8380

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

Upvotes: 1

SoulRayder
SoulRayder

Reputation: 5166

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.

Upvotes: 1

Related Questions