我有一个文本视图,里面有一个链接.在代码中,我打电话setMovementMethod给用户点击文本时打开链接.但它会在默认浏览器或浏览器选择器中打开它.
如何使用带有可点击文本视图的Chrome自定义标签?
我有按钮的活动.OnClick打开CustomTab:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.build().launchUrl(MainActivity.this, Uri.parse("https://www.google.com"));
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
关闭CustomTab后,MainActivity会以黑色闪烁.为什么会这样?我怎样才能解决这个问题?该问题例如由Nexus 5X android 8.0,Pixel 2 android 8.0重现
使用自定义动画:
android android-activity chrome-custom-tabs android-customtabs
嗨,我是自定义标签的新手,我只想隐藏操作栏.有没有办法做到这一点任何链接,代码和概念将提前感谢!
这是代码!
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left);
intentBuilder.setExitAnimations(this, android.R.anim.slide_in_left,
android.R.anim.slide_out_right);
//Open the Custom Tab
intentBuilder.build().launchUrl(context, Uri.parse("https://developer.chrome.com/"));
Run Code Online (Sandbox Code Playgroud) 我正在使用 AppAuth 库,我希望它使用自定义选项卡,但它永远不会在支持 Play 商店的模拟器上或在我的运行 Oreo 的 HTC U11 设备上使用。Chrome 已安装。我尝试了很多配置但没有运气。
val authService = AuthorizationService(applicationContext)
val authIntent = authService.getAuthorizationRequestIntent(authRequest,
authService.createCustomTabsIntentBuilder(Uri.parse(authorizationManager.openIdConfig!!.authorization_endpoint)).build())
startActivityForResult(authIntent, REQUEST_AUTH)
Run Code Online (Sandbox Code Playgroud)
我尝试使用和不使用 createCustomTabsIntentBuilder,无论哪种方式,结果都完全相同。图我缺少最后一块秘密武器,只是不知道它是什么。
一切工作正常,我确实获得了授权,其余代码工作正常,它只是始终使用外部浏览器。
** 已解决 ** 当前的 AppAuth 库不支持 AndroidX。我提取了该库的代码,将其作为模块添加到我的应用程序中,将代码更新为 AndroidX 并更改了一行以使用正确的 CustomTab 字符串,现在一切都按预期工作。
BrowserSelector.java 第 187 行现在是
serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
Run Code Online (Sandbox Code Playgroud) 我正在使用新推出的Chrome自定义标签,而不是使用网页浏览.这是他们文档的链接
以下是显示如何使用它的代码.
String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
Run Code Online (Sandbox Code Playgroud)
问题是我想为此添加Intent.EXTRA_REFERRER.下面是用他们自己的话从他们的博客复制的段落..
对于网站来说,跟踪流量来源通常非常重要.通过在启动自定义标签时设置引荐来源,确保让他们知道您正在向其发送用户
intent.putExtra(Intent.EXTRA_REFERRER,
Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + context.getPackageName()));
Run Code Online (Sandbox Code Playgroud)
我没有弄清楚为启动自定义标签而创建的任何意图..在哪里添加此行?如果有人遇到这个,请帮忙.
我已经实现了applinks来处理我域中的所有url,如下所示
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:scheme="http" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
但我想在customtabs中打开来自同一域的一些链接.我正在实现这个逻辑来调用customtabs中的那些链接
CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
@Override
public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) {
client.warmup(0L);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setInstantAppsEnabled(false);
builder.setToolbarColor(context.getResources().getColor(R.color.pure_white));
builder.setSecondaryToolbarColor(context.getResources().getColor(R.color.pure_white));
builder.setShowTitle(true);
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context,Uri.parse("http://www.example.com/unhandled"));
}
@Override
public void onServiceDisconnected(ComponentName name) {}
};
CustomTabsClient.bindCustomTabsService(context, "com.android.chrome", connection);
Run Code Online (Sandbox Code Playgroud)
但这些链接是我的applink意图捕获的,它继续循环.我错过了什么?任何想法或建议都会有用.
我要用CustomTabsIntent。但是我找不到androidx的customTabs路径和版本。
终于我明白了: androidx.browser:browser:1.0.0
我想知道正确的步骤。
我看到了,但是找不到路径和版本。 https://developer.android.com/reference/androidx/browser/customtabs/package-summary
我的步骤:
com.android.support:customtabs:28.0.0Refactor-> Migrate to AndroidX在Android Studio中我已经使用 Chrome 自定义选项卡构建了一个 Android 应用程序,但是当我单击按钮显示 URL 时,会出现一个对话框,提示我需要选择“打开方式”并列出所有可供选择的浏览器应用程序。我的问题是如何确定应用程序仅将 Chrome 设置为默认值,而不必再打开“打开方式”对话框。
fab.setOnClickListener {
val url = "http://myurl.com/"
val builder = CustomTabsIntent.Builder()
builder.setToolbarColor(ContextCompat.getColor(this@MainActivity,R.color.colorAccent))
builder.addDefaultShareMenuItem()
val anotherCustomTab = CustomTabsIntent.Builder().build()
val intent = anotherCustomTab.intent
intent.data = Uri.parse("http://myurl.com/")
builder.setShowTitle(true)
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(this@MainActivity, Uri.parse(url))
}
Run Code Online (Sandbox Code Playgroud) android android-webview kotlin chrome-custom-tabs android-customtabs
我在应用程序上使用的是Chrome自定义标签,我希望能够禁用一些在启动它以打开Google驱动器文件时自动弹出的按钮,即用于为页面添加书签的按钮和用于下载。我在网上搜索时都没有运气。
下面是突出显示该图像的图像,这些按钮正是我想要隐藏在自定义标签中的按钮。有人知道如何实现这一目标吗?提前非常感谢您。

如何在不打开后台 Google Chrome 的情况下在应用程序中打开自定义选项卡...
这是我的代码
String a="http://www.gpamravati.ac.in/gpamravati";
CustomTabsIntent.Builder builder=new CustomTabsIntent.Builder();
CustomTabsIntent custom=builder.build();
custom.intent.setPackage("com.android.chrome");
builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
custom.launchUrl(this, Uri.parse(a));
Run Code Online (Sandbox Code Playgroud)