当前位置:网站首页>Simulate activity startup mode in compose
Simulate activity startup mode in compose
2022-06-30 02:55:00 【Android】
About startup mode
We all know that activity There are many startup modes in the system :standard、singleTop、singleInstance、singleTask Four kinds of . But in compose Because it is a single activity So there is no such thing as a startup mode , So in this article I use some NavHostController Some of api To achieve the effect in startup mode .
standard
The default effect is standard The effect of
singleTop
compose We can determine whether the top page is what we want to launch singleTop Page to process .
If the top page is singleTop The top page is refreshed directly .
Judging code :
/** * Determine whether the top page is the page we want to route */
fun sameAsTopPage(controller: NavHostController,dstRoute: String):Boolean{
val distination = controller.currentDestination?.route ?: ""
return distination == dstRoute
}
singleTask
The way we do it , It will first determine whether there is a target page in the current routing stack , If it exists, it will go back to the target page , The middle page will be destroyed automatically
fun toSingleInstance(controller: NavHostController, route: String){
val findRoute = controller.findDestination(route)
if (findRoute == null){
controller.navigate(route)
}else{
controller.popBackStack()
controller.navigate(route)
}
}
singleSinstance
At present, we don't have a good way to implement the singleton mode , So there is no implementation here .
however compose The scenario of the single example in does not seem to exist , So it doesn't matter .
边栏推荐
- Uniapp address translation latitude and longitude
- Raki's notes on reading paper: Leveraging type descriptions for zero shot named entity recognition and classification
- Linear algebra Chapter 3 summary of vector and vector space knowledge points (Jeff's self perception)
- Servlet面试题
- What is a self signed certificate? Advantages and disadvantages of self signed SSL certificates?
- Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
- What about punctuation in the first column of unity text
- 2. successfully solved bug:exception when publishing [Failed to connect and initialize SSH connection...
- How to modify and add fields when MySQL table data is large
- HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification
猜你喜欢

公司电脑强制休眠的3种解决方案

How to use vant to realize data paging and drop-down loading

2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...

Unity3D UGUI强制刷新Layout(布局)组件

How to prevent phishing emails? S/mime mail certificate

High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()

Cmake tutorial series -02- generating binaries using cmake code

Recursion frog jumping steps problem

How to use redis to realize the like function

在php中字符串的概念是什么
随机推荐
中断操作:AbortController学习笔记
[dry goods sharing] the latest WHQL logo certification application process
Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share
How does native JS generate Jiugong lattice
迅为恩智浦iTOP-IMX6开发平台
自定义JvxeTable的按钮及备注下$set的用法
Call collections Sort() method, compare two person objects (by age ratio first, and by name ratio for the same age), and pass lambda expression as a parameter.
微信小程序页面跳转以及参数传递
Global and Chinese market for defense network security 2022-2028: Research Report on technology, participants, trends, market size and share
Distributed file storage system fastdfs hands on how to do it
CMake教程系列-02-使用cmake代码生成二进制
2.8 【 weight of complete binary tree 】
SQLite use
最小栈详解
How to prevent phishing emails? S/mime mail certificate
Azure developer news flash list of events of developers in June
Pytoch learning (II)
Linear algebra Chapter 3 summary of vector and vector space knowledge points (Jeff's self perception)
What is a self signed certificate? Advantages and disadvantages of self signed SSL certificates?
002 color classification