当前位置:网站首页>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();
}
}
}
边栏推荐
- Coordinate system of view
- Energy momentum: how to achieve carbon neutralization in the power industry?
- Jupiter notebook shortcut key
- Swift uses userdefaults and codable to save an array of class objects or structure instances
- [200 opencv routines] 219 Add digital watermark (blind watermark)
- La vue latérale du cycle affiche cinq demi - écrans en dessous de cinq distributions moyennes
- . Net delay queue
- leetcode:1200. 最小绝对差
- AtCoder Beginner Contest 258「ABCDEFG」
- To bring Euler's innovation to the world, SUSE should be the guide
猜你喜欢
《微信小程序-基础篇》小程序中的事件与冒泡
【 conseils 】 obtenir les valeurs des axes X et y de la fonction cdfplot dans MATLAB
RMS TO EAP通过MQTT简单实现
一种用于干式脑电图的高密度256通道电极帽
View Slide
Kotlin Compose 多个条目滚动
What is the origin of the domain knowledge network that drives the new idea of manufacturing industry upgrading?
Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 -下
IDEA新建sprintboot项目
Hard core, have you ever seen robots play "escape from the secret room"? (code attached)
随机推荐
QT timer realizes dynamic display of pictures
Constraintlayout officially provides rounded imagefilterview
驱动制造业产业升级新思路的领域知识网络,什么来头?
mongoDB副本集
The most complete is an I2C summary
How to plan the career of a programmer?
LiveData 面试题库、解答---LiveData 面试 7 连问~
学习笔记6--卫星定位技术(上)
Kotlin compose multiple item scrolling
Detailed explanation of the use of staticlayout
MySQL字符类型学习笔记
Apache dolphin scheduler system architecture design
Fluent generates icon prompt logo widget
Swift tableview style (I) system basic
学习笔记5--高精地图解决方案
The comparison of every() and some() in JS uses a power storage plan
Tianlong Babu TLBB series - about items dropped from packages
Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 -下
如何獲取GC(垃圾回收器)的STW(暫停)時間?
最全是一次I2C总结