当前位置:网站首页>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();
}
}
}
边栏推荐
- Personal website construction tutorial | local website environment construction | website production tutorial
- La vue latérale du cycle affiche cinq demi - écrans en dessous de cinq distributions moyennes
- Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 -下
- A high density 256 channel electrode cap for dry EEG
- C function returns multiple value methods
- Windows uses commands to run kotlin
- Unity particle special effects series - the poison spray preform is ready, and the unitypackage package is directly used - on
- Lepton 无损压缩原理及性能分析
- . Net delay queue
- 程序员如何活成自己喜欢的模样?
猜你喜欢

Redis如何实现多可用区?

RMS TO EAP通过MQTT简单实现

QT realizes signal transmission and reception between two windows

Mysql80 service does not start

一种用于干式脑电图的高密度256通道电极帽

Swift tableview style (I) system basic
![[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution](/img/f3/782246100bca3517d95869be80d9c5.png)
[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution

To bring Euler's innovation to the world, SUSE should be the guide

把欧拉的创新带向世界 SUSE 要做那个引路人

Have you learned to make money in Dingding, enterprise micro and Feishu?
随机推荐
《天天数学》连载58:二月二十七日
Cent7 Oracle database installation error
面试:Bitmap像素内存分配在堆内存还是在native中
Lepton 无损压缩原理及性能分析
mongoDB副本集
Cerebral Cortex:有向脑连接识别帕金森病中广泛存在的功能网络异常
@Jsonadapter annotation usage
基于单片机步进电机控制器设计(正转反转指示灯挡位)
《剑来》语句摘录(七)
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
Swift set pickerview to white on black background
Usage differences between isempty and isblank
学习笔记5--高精地图解决方案
@SerializedName注解使用
Advanced opencv:bgr pixel intensity map
MySQL character type learning notes
Openes version query
一种用于干式脑电图的高密度256通道电极帽
RMS TO EAP通过MQTT简单实现
Zblogphp breadcrumb navigation code