A
A
Anton Chekhov2017-04-23 22:18:58
Android
Anton Chekhov, 2017-04-23 22:18:58

How to monitor the launch of another application?

I want to write a program that will track the launch of applications (Vider, Telegram, WhatsApp), but I ran into a problem :
I get a list of running applications through

ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE) 
for (ApplicationInfo packageInfo : packages) {
if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue;
if(packageInfo.packageName.equals("org.telegram.messenger")) continue;
// выполнить код
}

This code works even when any service of this program is running. In Telegram, for example, this is NotificationsService. And I need to know that the Activity of the program is running.
Question:
how to track the launch of the messenger window?
PS You can track not the moment of launch itself, but the set interval to check whether it is running or not. But how to do that?
PPS If you think that I am writing a virus, then you are mistaken! The problem is much simpler: I have a girlfriend who knows the pattern of the phone. I wonder if she reads my correspondence or not)))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-04-24
@Sanasol

https://play.google.com/store/apps/details?id=com....
https://play.google.com/store/apps/details?id=com....
D - trust.
Love is...
Give her a password and make sure she doesn't read anything.

Z
z0rgoyok, 2017-04-23
@z0rgoyok

check date online

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question