android判断一个Activity是否处于栈顶的实例
作者:青穗QAQ 时间:2021-06-24 18:37:39
实际开发中我们需要很多情况需要判断某个activity是否位于栈顶,也许会给新的小伙伴带来困扰,那么直接上代码吧,也没几行
/**
*
* 判断某activity是否处于栈顶
* @return true在栈顶 false不在栈顶
*/
private boolean isActivityTop(Class cls,Context context){
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
String name = manager.getRunningTasks(1).get(0).topActivity.getClassName();
return name.equals(cls.getName());
}
来源:https://blog.csdn.net/fzkf9225/article/details/76616740
标签:android,判断,Activity,栈顶
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
c# 成员类型访问权限低于字段本身的实现
2021-12-23 07:08:27
![](https://img.aspxhome.com/file/2023/9/78129_0s.png)
Android Studio实现弹窗设置
2022-08-20 19:49:03
![](https://img.aspxhome.com/file/2023/5/88675_0s.jpg)
基于SSM框架+Javamail发送邮件的代码实例
2022-04-28 11:59:04
![](https://img.aspxhome.com/file/2023/6/110916_0s.png)
spring @Profiles和@PropertySource实现根据环境切换配置文件
2023-09-18 21:28:43
![](https://img.aspxhome.com/file/2023/6/104056_0s.png)
详解spring cloud ouath2中的资源服务器
2022-09-24 15:36:43
![](https://img.aspxhome.com/file/2023/8/61238_0s.png)
Android如何监听屏幕旋转
2021-12-15 06:12:50
![](https://img.aspxhome.com/file/2023/3/91693_0s.png)
Java的Struts框架简介与环境配置教程
2023-10-29 05:23:03
![](https://img.aspxhome.com/file/2023/8/58728_0s.jpg)
浅谈Spring事务传播行为实战
2022-07-04 01:54:44
![](https://img.aspxhome.com/file/2023/0/86860_0s.jpg)
Android实现闪屏页效果
2022-01-17 01:21:47
![](https://img.aspxhome.com/file/2023/2/110732_0s.jpg)
mybaties plus selectMaps和selectList的区别说明
2021-07-15 11:18:29
![](https://img.aspxhome.com/file/2023/5/68225_0s.png)
详述IntelliJ IDEA插件的安装及使用方法(图解)
2023-11-26 04:45:06
![](https://img.aspxhome.com/file/2023/3/60313_0s.png)
java获取时间的方法总结
2022-03-28 15:36:38
Java实现文件和base64流的相互转换功能示例
2023-11-18 07:45:01
Spring Boot JPA中使用@Entity和@Table的实现
2023-11-22 11:49:58
解析Java线程同步锁的选择方法
2023-02-08 11:02:32
SpringBoot v2.2以上重复读取Request Body内容的解决方案
2022-06-27 11:00:16
Java中对象的销毁方法分析
2023-01-09 16:44:29
SpringBoot消息国际化配置实现过程解析
2023-05-16 01:19:22
![](https://img.aspxhome.com/file/2023/5/67155_0s.png)
花样使用Handler与源码分析
2023-07-30 08:36:31
Android实现自定义华丽的水波纹效果
2023-10-03 23:12:50
![](https://img.aspxhome.com/file/2023/4/94244_0s.gif)