Is it possible to find the current foreground activity in android.I am not using ActivityGroup.
try below code : you need to give proper permission
private String getCurrentTopActivity() {
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List RunningTask = mActivityManager.getRunningTasks(1);
ActivityManager.RunningTaskInfo ar = RunningTask.get(0);
return ar.topActivity.getClassName().toString();
}