当前位置:网站首页>Learning Android from scratch -- baseactivity and activitycollector
Learning Android from scratch -- baseactivity and activitycollector
2022-04-23 04:47:00 【Scattered moon】
BaseActivity
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
open class BaseActivity:AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d("BaseActivity", javaClass.simpleName)
ActivityCollector.addActivity(this)
}
override fun onDestroy() {
super.onDestroy()
ActivityCollector.removeActivity(this)
}
}
ActivityCollector—— Exit the program anytime, anywhere
import android.app.Activity
object ActivityCollector {
private val activities = ArrayList<Activity>()
fun addActivity(activity: Activity) {
activities.add(activity)
}
fun removeActivity(activity: Activity) {
activities.remove(activity)
}
fun finishAll() {
for (activity in activities) {
if (!activity.isFinishing) {
activity.finish()
} }
activities.clear()
android.os.Process.killProcess(android.os.Process.myPid())
}
}
版权声明
本文为[Scattered moon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220555418213.html
边栏推荐
- 泰克示波器DPO3054自校准SPC失败维修
- Solutions to the failure of sqoop connection to MySQL
- Spark small case - RDD, spark SQL
- Summary of MySQL de duplication methods
- Innovation training (XI) airline ticket crawling company information
- leetcode007--判断字符串中的括号是否匹配
- C language: Advanced pointer
- JS generates a specified number of characters according to some words
- Logger and zap log Library in go language
- Leetcode004 -- Roman numeral to integer
猜你喜欢

Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data

Windows remote connection to redis

Small volume Schottky diode compatible with nsr20f30nxt5g

拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!

Innovation training (VI) routing

Supplement 14: cmake practice project notes (to be continued 4 / 22)

QML进阶(五)-通过粒子模拟系统实现各种炫酷的特效

Summary of MySQL de duplication methods

IDE idea automatic compilation and configuration of on update action and on frame deactivation

Unity RawImage背景无缝连接移动
随机推荐
leetcode006--查找字符串数组中的最长公共前缀
The object needs to add additional attributes. There is no need to add attributes in the entity. The required information is returned
test
Small volume Schottky diode compatible with nsr20f30nxt5g
Recommended scheme of national manufactured electronic components
PIP3 installation requests Library - the most complete pit sorting
redis和mysql区别
unity摄像机旋转带有滑动效果(自转)
The programmer starts the required application with one click of window bat
Create VPC in AWS console (no plate)
【数据库】MySQL单表查询
Spark case - wordcount
Spark optimization
test
selenium模式下切换窗口,抓取数据的实现
Spark FAQ sorting - must see before interview
[paper reading] [3D target detection] point transformer
用LCR表完美测试无线充电系统中的线圈
Supplement 14: cmake practice project notes (to be continued 4 / 22)
Gets all dates between two times