At some point you'll find yourself needing to get information about the activities running in a certain task. There's an easy way of getting a list of running tasks from the ActivityManager service. You can request a maximum number of tasks running on the phone, and by default, the currently active task is returned first.
Once you have that you can get a ComponentName object by requesting the topActivity from your list.