Martin
Martin

Reputation: 31

Loading a Chrome Custom Tab in the background and trigger on NAVIGATION_FINISHED on Android

I'm using Chrome Custom Tab on Android and I want to load the url in the background and wait for NAVIGATION_FINISHED to trigger before showing (or not showing) the page to the user.

I have been able to get the NAVIGATION_FINISHED to trigger, but from what I can se in the docs and examples there is now way to actually load a URL without showing it to the user. I have tried warmup and the mayLaunchUrl(..) methods but they don't actually load the url (which makes sense).

If anyone can tell me that it's a) possible and how to do it or b) not possible so stop trying, that would be a great help. Thanks.

Upvotes: 1

Views: 1717

Answers (1)

andreban
andreban

Reputation: 4976

To pre-load content before opening the page, use mayLaunchUrl. It will go all the way until pre-rendering the page to the user.

I would recommend reading the best practices. The current recommendation is to pre-render when there's at least a 50% change of the user opening the page.

If the likelyhood is lower than that, you can use the low confidence pre-fetch: call mayLaunchUrl with null in the first parameter the desired url in the bundle list on the 3rd parameter. This will resolve DNS and pre-connect to the server, but won't fetch the whole page.

Upvotes: 1

Related Questions