How to open already opened activity instead of creating new one?

前端 未结 4 1187
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 17:49

I have two activities with \"navigation menu\" which has items for launching Activity1 and Activity2. For example we starts Activity2 from Activity1 and then we want open Ac

4条回答
  •  攒了一身酷
    2020-12-28 18:24

    add android:launchMode="singleTop" to your activity in the Manifest.xml

    
    

    Check this out about different launchModes also mind this:

    As shown in the table above, standard is the default mode and is appropriate for most types of activities. SingleTop is also a common and useful launch mode for many types of activities. The other modes — singleTask and singleInstance — are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications

提交回复
热议问题