FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS excludes whole application, not only the Activity

后端 未结 2 1577
执念已碎
执念已碎 2020-12-17 02:53

I have a Notification which starts an Activity. After a long press on home button and selecting my app, I want to start my main Activity again, and not this Activity started

2条回答
  •  温柔的废话
    2020-12-17 03:38

    It's not clear to me what you want.

    "How can I have my app in the recents, but have the main Activity started?"

    If you want to always start one activity using the long home-press, you can define your activity as singleTask in the manifest.

    That way, when you select the shortcut in the long press HOME, it will always show the MAIN, singleTask activity. I say this because I used this behavior before once. ;-)

    I believe that by using this you can still start an activity from the notification normally, using, say, Intents.

    In the activity tag:

            android:launchMode="singleTask"
            >
    
            
                
                
            
        
    

提交回复
热议问题