Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.List; import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; public class Main { public static ComponentName getTopActivityCompomentName(Context paramContext) { List<ActivityManager.RunningTaskInfo> localList = null; if (paramContext != null) { ActivityManager localActivityManager = (ActivityManager) paramContext.getSystemService("activity"); if (localActivityManager != null) { localList = localActivityManager.getRunningTasks(1); if ((localList == null) || (localList.size() <= 0)) { return null; } } } ComponentName localComponentName = localList.get(0).topActivity; return localComponentName; } }