Chrome browser for Lollipop and above introduced a nice feature to show tabs as separate tasks in Recent Apps Overview. Users can turn off this feature via settings. For some reason, this was only supported from Lollipop and not for older versions of Android. This is most likely due to SDK APIs introduced in API level 21, ActivityManager.AppTask. This is meant for applications wanting to manage tasks in recent apps overview. Applications can determine how and when activities appear in the overview screen. Chrome browser is most likely using these APIs restricting the feature to Lollipop and above.
Besides, Chrome also has the ability to resume the last used task when users launch the browser via launcher's shortcut. In a typical android application, android's launcher shortcut would always fire a specific intent resolving to the main activity of the application. In case of Chrome, this action is mapped to launch the last used tab and not the first tab. How is this implemented? Are there any hooks that applications can register with the framework? This is even more challenging as android supports third party launchers. Turns out, this is most likely extra bookkeeping done by Chrome (thanks to a crash report).
ChromeLauncherActivity seems to be the main activity launched via launcher shortcut. This in turn seems to be aware of the last used tab and the corresponding activity (DocumentActivity). From here on, it just uses the corresponding AppTask and requests for it to be moved to front. As a side note, the activity for each tab, DocumentActivity doesn't have a taskAffinity.
Besides, Chrome also has the ability to resume the last used task when users launch the browser via launcher's shortcut. In a typical android application, android's launcher shortcut would always fire a specific intent resolving to the main activity of the application. In case of Chrome, this action is mapped to launch the last used tab and not the first tab. How is this implemented? Are there any hooks that applications can register with the framework? This is even more challenging as android supports third party launchers. Turns out, this is most likely extra bookkeeping done by Chrome (thanks to a crash report).
android.app.IAppTask$Stub$Proxy.moveToFront(IAppTask.java:172) android.app.ActivityManager$AppTask.moveToFront(ActivityManager.java:2742) com.google.android.apps.chrome.document.ChromeLauncherActivity.relaunchTask(ChromeLauncherActivity.java:458) com.google.android.apps.chrome.document.ChromeLauncherActivity.launchLastViewedActivity(ChromeLauncherActivity.java:254) com.google.android.apps.chrome.document.ChromeLauncherActivity.handleIntent(ChromeLauncherActivity.java:180) com.google.android.apps.chrome.document.ChromeLauncherActivity.onCreate(ChromeLauncherActivity.java:104) android.app.Activity.performCreate(Activity.java:5977) android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
ChromeLauncherActivity seems to be the main activity launched via launcher shortcut. This in turn seems to be aware of the last used tab and the corresponding activity (DocumentActivity). From here on, it just uses the corresponding AppTask and requests for it to be moved to front. As a side note, the activity for each tab, DocumentActivity doesn't have a taskAffinity.
1 comment:
Great blog, I really liked it, do share more updates. Thank you. Check out at : Nursing Career Information In New York
Post a Comment