- MainActivity
- SecondActivity
Шаг 1: Теперь я запускаю MainActivity с помощью adb оболочка, я начинаю -n com.study.launch/.MainActivity и стек задач становится следующим:
* [0] MainAcitivty
Это нормально, потому что, как и ожидалось, создается новый экземпляр MainActivity.
Шаг 2. Затем я запускаю SecondActivity с помощью команды adb Shell am start -n com.study.launch/.SecondActivity и стек задач становится следующим:
* [1] SecondAcitivty
* [0] MainAcitivty
Это нормально, потому что, как и ожидалось, создается новый экземпляр SecondActivity, а поскольку Affnity по умолчанию использует имя пакета приложения, оно помещается в ту же задачу, хотя НОВЫЙ ФЛАГ ЗАДАЧИ устанавливается при запуске.
Шаг 3. Затем я снова запускаю SecondActivity с помощью оболочки adb am start -n com.study.launch/.SecondActivity и команды задача стек становится:
* [2] SecondAcitivty
* [1] SecondAcitivty
* [0] MainAcitivity
Это нормально, потому что, как и ожидалось, создается новый экземпляр SecondActivity.
Шаг 4. Наконец, я снова запускаю MainActivity с помощью команды Оболочка adb am start -n com.study.launch/.MainActivity. в результате выдает мне предупреждение:
Starting: Intent { cmp=com.study.launch/.MainActivity }
Warning: Activity not started, intent has been delivered to currently running top-most instance.
Проверяем стек задач: он все еще сохраняется:
* [2] SecondAcitivty
* [1] SecondAcitivty
* [0] MainAcitivity
Мой вопрос: почему не создается новый экземпляр MainActivity?
На этом этапе при выгрузке действий стек задач выглядит следующим образом:
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):
Stack #2970: type=standard mode=fullscreen
isSleeping=false
mBounds=Rect(0, 0 - 0, 0)
mResumedActivity: ActivityRecord{4165bf9 u0 com.study.launch/.SecondActivity t2970}
* Task{e640079 #2970 visible=true type=standard mode=fullscreen translucent=false A=10353:com.study.launch U=0 StackId=2970 sz=3}
mBounds=Rect(0, 0 - 0, 0)
mMinWidth=-1 mMinHeight=-1
userId=0 effectiveUid=u0a353 mCallingUid=2000 mUserSetupComplete=true mCallingPackage=com.android.shell mCallingFeatureId=null
affinity=10353:com.study.launch
intent={flg=0x10000000 cmp=com.study.launch/.MainActivity}
mActivityComponent=com.study.launch/.MainActivity
autoRemoveRecents=false isPersistable=true activityType=1
rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
Activities=[ActivityRecord{bcbe940 u0 com.study.launch/.MainActivity t2970}, ActivityRecord{be1bac4 u0 com.study.launch/.SecondActivity t2970}, ActivityRecord{4165bf9 u0 com.study.launch/.SecondActivity t2970}]
askedCompatMode=false inRecents=true isAvailable=true
mRootProcess=ProcessRecord{f26596c 18860:com.study.launch/u0a353}
taskId=2970 stackId=2970
mHasBeenVisible=true
mResizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION mSupportsPictureInPicture=false isResizeable=true
lastActiveTime=932630195 (inactive for 208s)
* Hist #2: ActivityRecord{4165bf9 u0 com.study.launch/.SecondActivity t2970}
packageName=com.study.launch processName=com.study.launch
launchedFromUid=2000 launchedFromPackage=com.android.shell launchedFromFeature=null userId=0
app=ProcessRecord{f26596c 18860:com.study.launch/u0a353}
Intent { flg=0x10000000 cmp=com.study.launch/.SecondActivity }
rootOfTask=false task=Task{e640079 #2970 visible=true type=standard mode=fullscreen translucent=false A=10353:com.study.launch U=0 StackId=2970 sz=3}
taskAffinity=10353:com.study.launch
mActivityComponent=com.study.launch/.SecondActivity
baseDir=/data/app/~~16sf25MRe03beHbyI0Sc3g==/com.study.launch-SSF_oypq9Ln-G52kGNzmdw==/base.apk
dataDir=/data/user/0/com.study.launch
stateNotNeeded=false componentSpecified=false mActivityType=standard
compat={560dpi} labelRes=0x7f090055 icon=0x7f080001 theme=0x7f0a000a
mLastReportedConfigurations:
mGlobalConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.61}
mOverrideConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
CurrentConfiguration={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
taskDescription: label="null" icon=null iconResource=/0 iconFilename=null primaryColor=fff5f5f5
backgroundColor=fffafafa statusBarColor=0 navigationBarColor=0
launchFailed=false launchCount=1 lastLaunchTime=-3m28s587ms
mHaveState=false mIcicle=null
state=RESUMED stopped=false delayedResume=false finishing=false
keysPaused=false inHistory=true setToSleep=false idle=true mStartingWindowState=STARTING_WINDOW_NOT_SHOWN
occludesParent=true noDisplay=false immersive=false launchMode=0
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=standard
windows=[Window{ef30aec u0 com.study.launch/com.study.launch.SecondActivity}]
windowType=2 hasVisible=true
mOccludesParent=true mOrientation=-1
mVisibleRequested=true mVisible=true mClientVisible=true reportedDrawn=true reportedVisible=true
mNumInterestingWindows=1 mNumDrawnWindows=1 allDrawn=true lastAllDrawn=true)
startingData=null firstWindowDrawn=true mIsExiting=false
nowVisible=true lastVisibleTime=-3m28s54ms
resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION
mLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=false
* Hist #1: ActivityRecord{be1bac4 u0 com.study.launch/.SecondActivity t2970}
packageName=com.study.launch processName=com.study.launch
launchedFromUid=2000 launchedFromPackage=com.android.shell launchedFromFeature=null userId=0
app=ProcessRecord{f26596c 18860:com.study.launch/u0a353}
Intent { flg=0x10000000 cmp=com.study.launch/.SecondActivity }
rootOfTask=false task=Task{e640079 #2970 visible=true type=standard mode=fullscreen translucent=false A=10353:com.study.launch U=0 StackId=2970 sz=3}
taskAffinity=10353:com.study.launch
mActivityComponent=com.study.launch/.SecondActivity
baseDir=/data/app/~~16sf25MRe03beHbyI0Sc3g==/com.study.launch-SSF_oypq9Ln-G52kGNzmdw==/base.apk
dataDir=/data/user/0/com.study.launch
stateNotNeeded=false componentSpecified=false mActivityType=standard
compat={560dpi} labelRes=0x7f090055 icon=0x7f080001 theme=0x7f0a000a
mLastReportedConfigurations:
mGlobalConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.61}
mOverrideConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
CurrentConfiguration={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
taskDescription: label="null" icon=null iconResource=/0 iconFilename=null primaryColor=fff5f5f5
backgroundColor=fffafafa statusBarColor=0 navigationBarColor=0
launchFailed=false launchCount=0 lastLaunchTime=-4m48s99ms
mHaveState=true mIcicle=Bundle[mParcelledData.dataSize=1380]
state=STOPPED stopped=true delayedResume=false finishing=false
keysPaused=false inHistory=true setToSleep=false idle=true mStartingWindowState=STARTING_WINDOW_NOT_SHOWN
occludesParent=true noDisplay=false immersive=false launchMode=0
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=standard
windows=[Window{4792473 u0 com.study.launch/com.study.launch.SecondActivity}]
windowType=2 hasVisible=true
mOccludesParent=true mOrientation=-1
mVisibleRequested=false mVisible=false mClientVisible=false reportedDrawn=false reportedVisible=false
mAppStopped=true
mNumInterestingWindows=1 mNumDrawnWindows=1 allDrawn=true lastAllDrawn=true)
startingData=null firstWindowDrawn=true mIsExiting=false
nowVisible=false lastVisibleTime=-4m47s573ms
resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION
mLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=false
* Hist #0: ActivityRecord{bcbe940 u0 com.study.launch/.MainActivity t2970}
packageName=com.study.launch processName=com.study.launch
launchedFromUid=2000 launchedFromPackage=com.android.shell launchedFromFeature=null userId=0
app=ProcessRecord{f26596c 18860:com.study.launch/u0a353}
Intent { flg=0x10000000 cmp=com.study.launch/.MainActivity }
rootOfTask=true task=Task{e640079 #2970 visible=true type=standard mode=fullscreen translucent=false A=10353:com.study.launch U=0 StackId=2970 sz=3}
taskAffinity=10353:com.study.launch
mActivityComponent=com.study.launch/.MainActivity
baseDir=/data/app/~~16sf25MRe03beHbyI0Sc3g==/com.study.launch-SSF_oypq9Ln-G52kGNzmdw==/base.apk
dataDir=/data/user/0/com.study.launch
stateNotNeeded=false componentSpecified=false mActivityType=standard
compat={560dpi} labelRes=0x7f090001 icon=0x7f080001 theme=0x7f0a000a
mLastReportedConfigurations:
mGlobalConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.61}
mOverrideConfig={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
CurrentConfiguration={1.0 ?mcc?mnc [zh_CN] ldltr sw411dp w411dp h659dp 560dpi nrml port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1440, 2560) mAppBounds=Rect(0, 0 - 1440, 2392) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
taskDescription: label="null" icon=null iconResource=/0 iconFilename=null primaryColor=fff5f5f5
backgroundColor=fffafafa statusBarColor=0 navigationBarColor=0
launchFailed=false launchCount=0 lastLaunchTime=-5m43s524ms
mHaveState=true mIcicle=Bundle[mParcelledData.dataSize=1380]
state=STOPPED stopped=true delayedResume=false finishing=false
keysPaused=false inHistory=true setToSleep=false idle=true mStartingWindowState=STARTING_WINDOW_REMOVED
occludesParent=true noDisplay=false immersive=false launchMode=0
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=standard
windows=[Window{76c0bff u0 com.study.launch/com.study.launch.MainActivity}]
windowType=2 hasVisible=true
mOccludesParent=true mOrientation=-1
mVisibleRequested=false mVisible=false mClientVisible=false reportedDrawn=false reportedVisible=false
mAppStopped=true
mNumInterestingWindows=1 mNumDrawnWindows=1 allDrawn=true lastAllDrawn=true)
startingData=null firstWindowDrawn=true mIsExiting=false
nowVisible=false lastVisibleTime=-5m41s774ms
resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION
mLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=false
Подробнее здесь: https://stackoverflow.com/questions/792 ... in-android