2013-07-23

Android API to get Activity name of current top Application

ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1);
Log.d(TAG, "Current activity: "+taskInfo.get(0).topActivity.getClassName());
ComponentName componentInfo = taskInfo.get(0).topActivity;
Log.d(TAG, "Current top application: "+componentInfo.getPackageName());

No comments: