Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; public class Main { public static String getTopActivityClassName(Context context) { try { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getClassName(); } catch (Exception e) { e.printStackTrace(); return null; } } }