Use ActivityManager to get the activity stack position you want
You can use the following code example
ActivityManager mngr = (ActivityManager) getSystemService( ACTIVITY_SERVICE ); List<ActivityManager.RunningTaskInfo> taskList = mngr.getRunningTasks(10);
to get the activity position you want to use the code below for ur request
taskList.get(0).topActivity.getClassName()
and the beginning of the position from o (zero).
Hope this helps you.
source share