说明:
1, com.gionee.filemanager/.FileExplorerTabActivity这个Activity启动com.gionee.filemanager/.privatespace.PrivateActivity
2, 其中com.gionee.filemanager/.privatespace.PrivateActivity添加了如下taskAffinity属性
android:taskAffinity=".private"
3, com.gionee.filemanager/.FileExplorerTabActivity没有显示添加taskAffinity属性
测试结果如下:
两个Activity启动到了不同的Task中。
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):
Stack #1:
mFullscreen=true
mBounds=null
Task id #226
mFullscreen=true
mBounds=null
mMinWidth=-1
mMinHeight=-1
mLastNonFullscreenBounds=null
* TaskRecord{577c95 #226
A=.private U=0 StackId=1 sz=1}
userId=0 effectiveUid=u0a42 mCallingUid=u0a42 mUserSetupComplete=true mCallingPackage=com.gionee.filemanager
affinity=.private
intent={flg=0x10800000 cmp=com.gionee.filemanager/.privatespace.PrivateActivity}
realActivity=com.gionee.filemanager/.privatespace.PrivateActivity
autoRemoveRecents=false isPersistable=false numFullscreen=1 taskType=0 mTaskToReturnTo=0
rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
Activities=[ActivityRecord{c05944c u0 com.gionee.filemanager/.privatespace.PrivateActivity t226}]
askedCompatMode=false inRecents=true isAvailable=true
lastThumbnail=null lastThumbnailFile=/data/system_ce/0/recent_images/226_task_thumbnail.png
stackId=1
hasBeenVisible=true mResizeMode=RESIZE_MODE_UNRESIZEABLE isResizeable=false firstActiveTime=1495779462251 lastActiveTime=1495779462251 (inactive for 1s)
* Hist #0: ActivityRecord{c05944c u0
com.gionee.filemanager/.privatespace.PrivateActivity t226}
packageName=com.gionee.filemanager processName=com.gionee.filemanager
launchedFromUid=10042 launchedFromPackage=com.gionee.filemanager userId=0
app=ProcessRecord{4932993 16972:com.gionee.filemanager/u0a42}
Intent { flg=0x10800000 cmp=com.gionee.filemanager/.privatespace.PrivateActivity }
frontOfTask=true task=TaskRecord{577c95 #226 A=.private U=0 StackId=1 sz=1}
taskAffinity=.private
realActivity=com.gionee.filemanager/.privatespace.PrivateActivity
baseDir=/data/app/com.gionee.filemanager-2/base.apk
dataDir=/data/user/0/com.gionee.filemanager
stateNotNeeded=false componentSpecified=true mActivityType=0
compat={320dpi} labelRes=0x7f09002e icon=0x7f0201dc theme=0x7f080025
config={0.9 default ?mcc?mnc [zh_CN,en_US] ldltr sw360dp w360dp h616dp 320dpi nrml long port finger -keyb/v/h -nav/h s.6}
taskConfigOverride={1.0 default ?mcc?mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/?}
taskDescription: iconFilename=null label="null" color=fff5f5f5
launchFailed=false launchCount=1 lastLaunchTime=-1s836ms
haveState=false icicle=null
state=RESUMED stopped=false delayedResume=false finishing=false
keysPaused=false inHistory=true visible=true sleeping=false idle=true mStartingWindowState=STARTING_WINDOW_SHOWN
fullscreen=true noDisplay=false immersive=false launchMode=2
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=APPLICATION_ACTIVITY_TYPE
waitingVisible=false nowVisible=true lastVisibleTime=-1s566ms
resizeMode=RESIZE_MODE_UNRESIZEABLE
Task id #225
mFullscreen=true
mBounds=null
mMinWidth=-1
mMinHeight=-1
mLastNonFullscreenBounds=null
* TaskRecord{53dcede #225
A=com.gionee.filemanager U=0 StackId=1 sz=1}
userId=0 effectiveUid=u0a42 mCallingUid=u0a38 mUserSetupComplete=true mCallingPackage=com.gionee.amisystem
affinity=com.gionee.filemanager
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.gionee.filemanager/.FileExplorerTabActivity}
realActivity=com.gionee.filemanager/.FileExplorerTabActivity
autoRemoveRecents=false isPersistable=true numFullscreen=1 taskType=0 mTaskToReturnTo=1
rootWasReset=true mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
Activities=[ActivityRecord{7f1dca0 u0 com.gionee.filemanager/.FileExplorerTabActivity t225}]
askedCompatMode=false inRecents=true isAvailable=true
lastThumbnail=null lastThumbnailFile=/data/system_ce/0/recent_images/225_task_thumbnail.png
stackId=1
hasBeenVisible=true mResizeMode=RESIZE_MODE_UNRESIZEABLE isResizeable=false firstActiveTime=1495779462221 lastActiveTime=1495779462221 (inactive for 1s)
* Hist #0: ActivityRecord{7f1dca0 u0 com.gionee.filemanager/.FileExplorerTabActivity t225}
packageName=com.gionee.filemanager processName=com.gionee.filemanager
launchedFromUid=10038 launchedFromPackage=com.gionee.amisystem userId=0
app=ProcessRecord{4932993 16972:com.gionee.filemanager/u0a42}
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.gionee.filemanager/.FileExplorerTabActivity bnds=[528,444][696,636] }
frontOfTask=true task=TaskRecord{53dcede #225 A=com.gionee.filemanager U=0 StackId=1 sz=1}
taskAffinity=com.gionee.filemanager
realActivity=com.gionee.filemanager/.FileExplorerTabActivity
baseDir=/data/app/com.gionee.filemanager-2/base.apk
dataDir=/data/user/0/com.gionee.filemanager
stateNotNeeded=false componentSpecified=true mActivityType=0
compat={320dpi} labelRes=0x7f09002e icon=0x7f0201dc theme=0x7f080025
config={0.9 default ?mcc?mnc [zh_CN,en_US] ldltr sw360dp w360dp h616dp 320dpi nrml long port finger -keyb/v/h -nav/h s.6}
taskConfigOverride={1.0 default ?mcc?mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/?}
taskDescription: iconFilename=null label="null" color=fff5f5f5
launchFailed=false launchCount=0 lastLaunchTime=-1m2s664ms
haveState=true icicle=Bundle[EMPTY_PARCEL]
state=STOPPED stopped=true delayedResume=false finishing=false
keysPaused=false inHistory=true visible=false sleeping=false idle=true mStartingWindowState=STARTING_WINDOW_SHOWN
fullscreen=true noDisplay=false immersive=false launchMode=1
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=APPLICATION_ACTIVITY_TYPE
waitingVisible=false nowVisible=false lastVisibleTime=-1m2s87ms
connections=[ConnectionRecord{34cffc4 u0 CR com.android.providers.media/.MediaScannerService:@5457ad7}, ConnectionRecord{254e5e2 u0 CR com.android.providers.media/.MediaScannerService:@34ecead}, ConnectionRecord{65e8edf u0 CR com.android.providers.media/.MediaScannerService:@e13b97e}, ConnectionRecord{9b4d5f5 u0 CR com.android.providers.media/.MediaScannerService:@544f72c}]
resizeMode=RESIZE_MODE_UNRESIZEABLE
Running activities (most recent first):
TaskRecord{577c95 #226 A=.private U=0 StackId=1 sz=1}
Run #1: ActivityRecord{c05944c u0 com.gionee.filemanager/.privatespace.PrivateActivity t226}
TaskRecord{53dcede #225 A=com.gionee.filemanager U=0 StackId=1 sz=1}
Run #0: ActivityRecord{7f1dca0 u0 com.gionee.filemanager/.FileExplorerTabActivity t225}
mResumedActivity: ActivityRecord{c05944c u0 com.gionee.filemanager/.privatespace.PrivateActivity t226}
mLastPausedActivity: ActivityRecord{7f1dca0 u0 com.gionee.filemanager/.FileExplorerTabActivity t225}
参考:
http://blog.csdn.net/chenshijun0101/article/details/9409193