简体   繁体   中英

How to prevent an activity from being the root activity of a task

Is it possible to prevent an activity from becoming the root activity of a task? Can we mark it in the Manifest File?

UPDATE:

I have marked my activity's launch mode as android:launchMode="singleTask" to avoid multiple instances. What could be possible work-around in this case?

Just define that activity in android manifest file for eg.

<activity android:name=".MyActivity" />

Without giving any other attributes to it.

Actually, you do not need to do anything extra to prevent an activity to be the root activity. You just need to avoid adding following attributes while defining your activity in AndroidManifest.xml file.

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM