I am currently using this code to retrieve process name:
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
if(taskInfo.get(0).topActivity.getPackageName().equalsIgnoreCase("xxxxxxxx") != true){
////com.xxx.xxx
}
What I am trying to achieve is to get the active 'window' title, for example, when I open a web browser the title is "www.google.com" and if I open a conversation with Mister X in SMS/MMS, the current title is "Mister X 0245478767".