I need to call activity with different launchMode
according to my app state. In one case it should be singleInstance
, in other - singleTask
. I know how to set launchMode
in AndroidManifest, but since it should be dynamic property I have to do it from code. I thought, that I can add some specific flag to intent, before starting activity, but I found only singleTop
flag. So is any way to solve this issue?
Thanks
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
In my case I need two different launchMode related to different android API level: in AndroidManifest
and different integers value inside folders values-18, values-21
launchmode 1 == singleTop singleTask == 2
Just create two Activities A and B, B extends A. In manifest declare launchMode="singleTask" for A, and launchMode="singleInstance" for B. And start the Activity according to launchMode you need.
After some investigations I've noticed that it is impossible to do that in such way. But good news is that i've got some workaround:
You have to create two
Activities
, each with corresponding launchModes. OneActivity
is realActivity
with your code inside, and another one will just call mainActivity
inonCreate()
method, but since it will have needed launchMode, mainActivity
will be launched with that mode. Not very nice, but completely working solution.After that, instead of trying open your
Activity
with intent flags, put in intentclass
of theActivity
according to launchMode you need.