RunningTasks

标签: RunningTasks

Android获取当前运行的Activity信息

ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); RunningTaskInfo info = manager.getRunningTasks(1).get(0); String shortClassName = info.topActivity.getShortClassName(); //类名 String className = info.topActivity.getClassName();//完整类名 String packageName = info.topActivity.getPackageName(); //包名 需要注意的是,别忘了加权限啊啊啊!!!!如果不加权限报错信息 java.lang.SecurityException: Permission Denial: getTasks() from pid=12644, uid=10111 requires android.permission.GET_

阅读全文...