Android method for determining whether Activity is at the top
- 2021-01-02 21:59:23
- OfStack
This article illustrates Android's method for determining whether Activity is at the top. To share for your reference, the details are as follows:
private boolean isTopActivity(Activity activity)
{
ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
return cn.getClassName().contains(activity);
}
For more information about Android Activity, please refer to Android Programming: Summary of activity Techniques
I hope this article has been helpful in Android programming.