Unlike the answer to
Chrome Custom Tab does not go back to app
My app works correctly when pressing the x or using the back button. However, when the server redirects the user back to the app inside the custom tab the window does not close. The redirect is a javascript intent to deep link back into the app. If I use a browser and skip the custom tab the redirect works correctly and closes the browser window. I have tried several values for the launchMode and noHistory in the Manifest but it's not making any difference.
Skipping the Chrome tab and going straight to a browser is the only choice. The user experience with Tabs would be much, much better. The behavior seems to change with different Android versions and gets worse with Android 6 and 7. The only error I can find in the unfiltered adb logcat is: 12-28 23:58:50.580 3595-3713/? I/ActivityManager: Displayed com.modolabs.kand28/com.modolabs.kurogo.core.activity.LoginActivity: +117ms 12-28 23:58:50.590 32437-13513/? W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/com.android.chrome/files/android_ticl_service_state.bin
This says that ActivityManager has started LoginActivity inside my app as it should but the LoginActivity window is behind the Chrome Custom Tab. If I complete the user action that invokes the redirect and then manually close the tab using the X, then I can get to the app and I see it is doing what it is supposed to do. My app is not getting focus to be put in the foreground on top of the tab.
Anybody else seeing this? Any suggestions?