Monitor Currently Running Application
I am encountering a problem that i can't not solve for the moment. The purpose of the code is to monitor which applications are running at current moment. I used the following code and logged the resulting package name, it worked. ActivityManager am = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE); String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName(); Log.i("TTWYMonitor", packageName); But I use that code in a BroadcastReceiver , nothing happened. In manifest ,I declared an intent receiver android:name=".MonitorApplication. What should I do,