Can an Android app know when another Android app is running?

Suppose Foo Eggs apps are on the same Android device. For any application, you can get a list of all applications on the device. Is it possible for one application to know if another application has been running and for how long?

+3
source share
3 answers

You can get a list of installed applications using PacketManager . Code from here :

public class AppList extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PackageManager pm = this.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); List list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED); for (ResolveInfo rInfo : list) { Log.w("Installed Applications", rInfo.activityInfo.applicationInfo .loadLabel(pm).toString()); } } 

To see current applications, you can use ActivityManager .

+4
source

This post explains how you can achieve this functionality in a general way.

This post , and this one has fragments of activity that lists running applications using ActivityManager getRunningAppProcesses() .

This post explains how to get a list of all installed applications, and then select one of them.

+1
source

Take a look at the ActivityManager .

0
source

All Articles