如果要获取实例,可通过使用一个局部public且static变量,在每生成一个Activity时,进行赋值,经试验,可行
http://wangzhigang2.iteye.com/blog/1276923
================================================
打印出来的结果就是包路径加类名
代码:- ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- List<RunningTaskInfo> runningTasks = am.getRunningTasks(1);
- RunningTaskInfo rti = runningTasks.get(0);
- ComponentName component = rti.topActivity;
- Log.i("tracy", component.getClassName());
记得要加个权限:
<uses-permission android:name="android.permission.GET_TASKS"></uses-permission>