Android Chrome Custom Tabs

Reference documentation

API documentation

Link

Chrome Custom Tabs Reference Documentation

https://developer.chrome.com/docs/android/custom-tabs/

Chrome Custom Tabs Best Practices_customtabs_Just_Sanpark's Blog-CSDN Blog

Chrome Custom Tabs best practices_chrome custom tabs integration_wxx614817's blog-CSDN blog

Chrome Custom Tabs Usage

Official Link document

 

Security:

Official Link document

 

Can the Chrome Custom Tabs page obtain keyboard input information and keyboard focus?

  • In Android, Chrome Custom Tabs do not directly provide applications with the ability to access the user's input or keyboard focus. Chrome Custom Tabs are designed to provide a consistent browser experience within apps while protecting user privacy and security.

  • Chrome Custom Tabs run as part of the Chrome browser and handle user input and interaction in a sandbox environment. Applications cannot directly access or intercept user input in Chrome Custom Tabs. Keyboard focus and input information are managed and handled by the Chrome browser.

What are Custom Tabs?

When a user clicks on a URL, should it be opened with a browser or with the application's built-in WebView?

Both options face some problems. Opening through the browser is a very heavy context switch and is not customizable. WebView cannot share data with the browser and needs to manually handle more scenarios.

Chrome Custom Tabs gives APPs more control when browsing web pages. Without using WebView, this not only ensures smooth switching between Native APPs and web pages, but also allows APPs to customize the appearance and operation of Chrome. The definable content is as follows:

  • toolbar color

  • Entry and exit animations

  • Add custom operations to Chrome's toolbar, overflow menu and bottom toolbar

Moreover, Chrome Custom Tabs allows developers to pre-launch Chrome and pre-load web content to improve loading speed.

When to choose between WebView and Chrome Custom Tabs?

If the web content to be displayed is controlled by you, and the web content needs to interact with Android components, such as calling some functions of the Android system through the JavaScript interface, in this case you also need to use WebView to implement it; in other cases, it is
OK Use Chrome Custom Tabs to achieve this.

What happens if a user doesn't have the latest version of Chrome installed?

Custom Tabs customize the UI through ACTION_VIEW Intent with key Extras. This means that the page to be opened will be opened through the system browser or the user's default browser.

There are some security differences between Chrome Custom Tabs, WebView, and the system browser:

  1. Chrome Custom Tabs (CCT): Chrome Custom Tabs is a solution integrated into the Chrome browser experience that provides a way to load and display web content within an application. Because it uses the Chrome browser, it gets Chrome's security and updates. CCT can benefit from Chrome browser security features such as safe browsing, automatic updates, and protection against malicious websites.

  2. WebView: WebView is a component provided by the Android platform that allows embedding and displaying web content within applications. The security of WebView mainly depends on the Android system's WebView implementation and the WebView version used. Therefore, security may be affected by device manufacturer and operating system version. For WebView, it is important to keep your device updated with the latest system and WebView security fixes.

  3. System browser: The system browser is usually the default browser that comes with the device, such as "Browser" or "Safari" on Android devices. The security of your system browser depends primarily on implementation and updates by the operating system vendor. System browsers may have broader security features and more frequent updates than WebView and CCT, since they are typically the responsibility of the operating system vendor.

Overall, Chrome Custom Tabs and the system browser have the advantage when it comes to security because they benefit from Chrome browser security features and updates. But no matter which solution you use, you need to ensure that your devices are updated with the latest security fixes and protections, and that you have appropriate security measures in place to verify and filter the content of loaded web pages.

Chrome Custom Tabs integration:

App build gradle:

// Chrome Custom Tabs
implementation 'androidx.browser:browser:1.3.0'

Activity code:

val linkStr = WpkUSApi.getInstance().oauthLink
val intent = CustomTabsIntent.Builder()
                .build()
intent.launchUrl(this, Uri.parse(linkStr))

Guess you like

Origin blog.csdn.net/zyy_give/article/details/131206550