Android WebView Wrapper(应用内浏览器)行为
Android WebView Wrapper (In-App Browser) behavior
在 Android 的最新版本中,从 Google 搜索打开 link 它会在 Google 搜索应用程序中打开 Chrome 的包装版本它在 'open with Chrome' 的菜单上提供了一个选项。这种常见模式也出现在其他应用程序上,如 Facebook、Twitter 等。所以基本上它会在应用程序内的 'WebView wrapper' 上打开 link,而不是打开浏览器应用程序。
在 Google 搜索中发现一件有趣的事情,当您单击 'open with Chrome' 时,它会非常平滑地过渡到 Chrome,就像它会转化为Chrome。
是否有任何示例或库可以帮助或包装此行为?或包装此 activity 行为的 'in-app browser'。
您可能正在寻找 Chrome Custom Tabs 正如张忠礼已经提到的那样。
将 implementation "androidx.browser:browser:1.3.0"
添加到您的 build.gradle 文件。
您可以像这样打开一个新标签页:
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse("https://www.example.com"));
可以在 Implementation guide.
中找到更多示例
在 Android 的最新版本中,从 Google 搜索打开 link 它会在 Google 搜索应用程序中打开 Chrome 的包装版本它在 'open with Chrome' 的菜单上提供了一个选项。这种常见模式也出现在其他应用程序上,如 Facebook、Twitter 等。所以基本上它会在应用程序内的 'WebView wrapper' 上打开 link,而不是打开浏览器应用程序。
在 Google 搜索中发现一件有趣的事情,当您单击 'open with Chrome' 时,它会非常平滑地过渡到 Chrome,就像它会转化为Chrome。
是否有任何示例或库可以帮助或包装此行为?或包装此 activity 行为的 'in-app browser'。
您可能正在寻找 Chrome Custom Tabs 正如张忠礼已经提到的那样。
将 implementation "androidx.browser:browser:1.3.0"
添加到您的 build.gradle 文件。
您可以像这样打开一个新标签页:
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse("https://www.example.com"));
可以在 Implementation guide.
中找到更多示例