ActivityManager.RunningTaskInfo
谁能解释为什么我在调用这里的代码片段时总是遇到 runtimeException :
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> listInfo = am.getRunningTasks(2);
ActivityManager.RunningTaskInfo taskInfo = listInfo.get(0);//it throws exception in this line
TextView title = (TextView) findViewById(R.id.textView_Settings_Title);
title.setText(taskInfo.topActivity.getClassName().toString());