there are lots of question about this topic but all are only about getting the package name. what i want is get the activity name.
currently i am using the below method to get the activity name but as you know ActivityManager.getRunningTasks is now deprecated, so is there an alternative way to get this or i should stick with this and it won't do any harm?
ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1); //deprecated
//taskInfo.get(0).topActivity.getClassName() //this gets the activity name