当前位置:网站首页>Singleton mode encapsulates activity management class
Singleton mode encapsulates activity management class
2022-07-05 10:16:00 【asahi_ xin】
public class AppManager {
private Stack<Activity> activityStack;
private AppManager() {
activityStack = new Stack<>();
}
public static AppManager getInstance() {
return AppHolder.appManager;
}
private static class AppHolder {
private static AppManager appManager = new AppManager();
}
/** * add to activity * * @param activity activity */
public void addActivity(Activity activity) {
activityStack.add(activity);
}
/** * remove activity * * @param activity activity */
public void removeActivity(Activity activity) {
activityStack.remove(activity);
}
/** * Get current Activity */
private Activity currentActivity() {
return activityStack.lastElement();
}
/** * Remove and close activity * * @param activity activity */
public void finishActivity(Activity activity) {
removeActivity(activity);
activity.finish();
}
/** * Remove and close all activity */
public void finishAllActivity() {
for (Activity activity : activityStack) {
if (null != activity) {
activity.finish();
}
}
activityStack.clear();
}
/** * sign out app Called when the */
public void exitApp() {
try {
finishAllActivity();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}
边栏推荐
- [tips] get the x-axis and y-axis values of cdfplot function in MATLAB
- > Could not create task ‘:app:MyTest.main()‘. > SourceSet with name ‘main‘ not found.问题修复
- 官网给的这个依赖是不是应该为flink-sql-connector-mysql-cdc啊,加了依赖调
- Excerpt from "sword comes" (VII)
- MySQL字符类型学习笔记
- 把欧拉的创新带向世界 SUSE 要做那个引路人
- A large number of virtual anchors in station B were collectively forced to refund: revenue evaporated, but they still owe station B; Jobs was posthumously awarded the U.S. presidential medal of freedo
- 基于单片机步进电机控制器设计(正转反转指示灯挡位)
- AtCoder Beginner Contest 258「ABCDEFG」
- 请问大佬们 有遇到过flink cdc mongdb 执行flinksql 遇到这样的问题的么?
猜你喜欢

学习笔记4--高精度地图关键技术(下)

ArcGIS Pro 创建要素

学习笔记5--高精地图解决方案

Mysql80 service does not start

Kotlin Compose 与原生 嵌套使用

Wechat applet - simple diet recommendation (2)

Cut off 20% of Imagenet data volume, and the performance of the model will not decline! Meta Stanford et al. Proposed a new method, using knowledge distillation to slim down the data set

字节跳动面试官:一张图片占据的内存大小是如何计算

Unity particle special effects series - the poison spray preform is ready, and the unitypackage package is directly used - on

@SerializedName注解使用
随机推荐
Meitu lost 300 million yuan in currency speculation for half a year. Huawei was exposed to expand its enrollment in Russia. Alphago's peers have made another breakthrough in chess. Today, more big new
The comparison of every() and some() in JS uses a power storage plan
橫向滾動的RecycleView一屏顯示五個半,低於五個平均分布
Getting started with Apache dolphin scheduler (one article is enough)
Glide advanced level
B站大量虚拟主播被集体强制退款:收入蒸发,还倒欠B站;乔布斯被追授美国总统自由勋章;Grafana 9 发布|极客头条...
小程序中自定义行内左滑按钮,类似于qq和wx消息界面那种
Dedecms website building tutorial
Is it really reliable for AI to make complex decisions for enterprises? Participate in the live broadcast, Dr. Stanford to share his choice | qubit · viewpoint
Design and Simulation of fuzzy PID control system for liquid level of double tank (matlab/simulink)
QT timer realizes dynamic display of pictures
【小技巧】获取matlab中cdfplot函数的x轴,y轴的数值
isEmpty 和 isBlank 的用法区别
自动化规范检查软件如何发展而来?
如何写出高质量的代码?
.Net之延迟队列
[system design] index monitoring and alarm system
The essence of persuasion is to remove obstacles
面试:List 如何根据对象的属性去重?
【系统设计】指标监控和告警系统