service+ActivityManager....
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<RunningTaskInfo> TaskList = am.getRunningTasks(2);
if(TaskList == null || TaskList.isEmpty())
return;
RunningTaskInfo rti = TaskList.get(0);
String tmp = rti.topActivity.getPackageName();
-------
List<RunningTaskInfo> TaskList = am.getRunningTasks(2);
if(TaskList == null || TaskList.isEmpty())
return;
RunningTaskInfo rti = TaskList.get(0);
String tmp = rti.topActivity.getPackageName();
-------
tmp就是包名