Code example for List

Methods: iterator

0
		final String CONVO_CLASS_NAME = "com.android.mms.ui.ConversationList";
 
		ActivityManager mAM = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
 
		List<RunningTaskInfo> mRunningTaskList = mAM.getRunningTasks(1);
		Iterator<RunningTaskInfo> mIterator = mRunningTaskList.iterator();
		if (mIterator.hasNext()) {
			RunningTaskInfo mRunningTask = mIterator.next();
			if (mRunningTask != null) {
				ComponentName runningTaskComponent = mRunningTask.baseActivity;
 
				// //Log.v("baseActivity = " + 
				// mRunningTask.baseActivity.toString()); 
				// //Log.v("topActivity = " + 
				// mRunningTask.topActivity.toString()); 
 
				if (PACKAGE_NAME.equals(runningTaskComponent.getPackageName())
						&& CONVO_CLASS_NAME.equals(runningTaskComponent.getClassName())) {
					// Log.v("User in messaging app - from running task"); 
					return true; 
				}