本文实例讲述了Android判断Activity是否在最上层的方法。分享给大家供大家参考,具体如下:
1
2
3
4
5
6
|
private boolean isTopActivity(Activity activity) { ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks( 1 ).get( 0 ).topActivity; return cn.getClassName().contains(activity); } |
希望本文所述对大家Android程序设计有所帮助。