我正在尝试实现自定义Chrome标签.我正在使用Google的默认库customtabs.
我引用本教程来实现自定义chrome选项卡.现在按照教程中的建议,我做了类似的编码.
mCustomTabsServiceConnection = new CustomTabsServiceConnection() {
@Override
public void onCustomTabsServiceConnected(
ComponentName componentName,
CustomTabsClient customTabsClient) {
mCustomTabsClient = customTabsClient;
mCustomTabsClient.warmup(0L);
mCustomTabsSession = mCustomTabsClient.newSession(null);
}
@Override
public void onServiceDisconnected(ComponentName name) {
mCustomTabsClient = null;
}
};
CustomTabsClient.bindCustomTabsService(this, "com.android.chrome",
mCustomTabsServiceConnection);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(
mCustomTabsSession).setShowTitle(true);
builder.setToolbarColor(getResources().getColor(R.color.purple_main));
builder.setStartAnimations(getApplicationContext(), R.anim.fadein,
R.anim.fadeout);
builder.setExitAnimations(getApplicationContext(), R.anim.fadein,
R.anim.fadeout);
mCustomTabsIntent = builder.build();
Run Code Online (Sandbox Code Playgroud)
并启动自定义标签.
mCustomTabsIntent.launchUrl(TampleDetails.this,
Uri.parse(temple_website));
Run Code Online (Sandbox Code Playgroud)
现在,如您所见,我已将自定义选项卡与chrome的包名绑定,但它仍然要求在Chrome和UC浏览器之间进行选择.很明显UC浏览器不支持自定义标签.
所以我的问题是如何限制自定义标签仅与Chrome浏览器绑定?
任何帮助将不胜感激.
谢谢.
Chrome自定义选项卡中是否有类似于Webview的onPageStarted的任何功能.IN onNavigation ..包总是为空
我正在实现后备Chrome自定义标签
我指的是几个具有自定义后备实现的链接 。我不明白为什么需要它。
我做了以下处理后备的工作,并且工作正常。
try {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(ContextCompat.getColor(context, R.color.appthemecolor));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Intent intent = new Intent(context, WebviewActivity.class);
intent.putExtra(WebviewActivity.EXTRA_URL, url);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
知道为什么需要这样复杂的实现来处理回退吗?
使用以下版本的支持库compile 'com.android.support:customtabs:25.3.1'
android android-webview android-support-library chrome-custom-tabs
android ×3