Android Chrome自定义选项卡在重定向时不会关闭
我正在使用chrome自定义选项卡获取oAuth连接请求,从自定义选项卡重定向。我在应用程序中成功重定向。唯一的问题是chrome自定义选项卡在重定向时不会关闭,而是留在堆栈中 在自定义选项卡中启动url的代码如下所示Android Chrome自定义选项卡在重定向时不会关闭,android,oauth-2.0,fitbit,chrome-custom-tabs,Android,Oauth 2.0,Fitbit,Chrome Custom Tabs,我正在使用chrome自定义选项卡获取oAuth连接请求,从自定义选项卡重定向。我在应用程序中成功重定向。唯一的问题是chrome自定义选项卡在重定向时不会关闭,而是留在堆栈中 在自定义选项卡中启动url的代码如下所示 customTabsIntent = new CustomTabsIntent.Builder(mCustomTabsSession) .setTool
customTabsIntent = new CustomTabsIntent.Builder(mCustomTabsSession)
.setToolbarColor(ContextCompat.getColor(getBaseContext(), R.color.colorPrimary))
.setStartAnimations(getBaseContext(),
R.anim.slide_in_right, R.anim.slide_out_left)
.setExitAnimations(getBaseContext(),
android.R.anim.slide_in_left, android.R.anim.slide_out_right)
.setShowTitle(true)
.build();
customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
customTabsIntent.launchUrl(Settings_Activity.this, Uri.parse(fitbitUrlBuilder.toString()));
我尝试在清单文件中使用“singleTask”和“singleInstance”,但问题仍然存在
如果我只使用intent“FLAG\u NO\u HISTORY”,它就可以工作。
但是我需要强制使用“FLAG_ACTIVITY_NEW_TASK”,因为存在特定的边缘情况,例如,如果特定站点的令牌被删除
我们尝试重新验证浏览器在android 7.1版上崩溃,需要再次手动启动应用程序
非常感谢您的帮助。在尝试验证oAuth提供商时,我遇到了同样的问题。我使用自定义选项卡25.3.1,并使用
addFlags
而不是setFlags
,使代码正常工作:
build.gradle
dependencies {
...
compile 'com.android.support:customtabs:25.3.1'
}
MyActivity.java
public void dispatchAuthIntent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// Use Chrome Custom Tabs
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(getBaseContext(), R.color.brand_blue_dark))
.setShowTitle(true)
.build();
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
// ...
}
崩溃是出问题的迹象。它会将什么打印到系统日志(可通过“adb logcat”查看的日志)?在其他Android版本上会发生这种情况吗?如果出现崩溃,请使用@EgorPasko中提到的bug模板提交bug,对于特定的边缘情况,没有崩溃,并且系统日志不会打印任何内容。这可能只是来自chrome定制标签的一个bug,我猜你可以针对定制标签提交一个bug(使用我提供的链接可以访问的链接:)?@EgorPasko当然可以:)@Sutirth,你好。我也在使用fitbit,但在从fitbit重定向到应用程序时遇到了问题。你能看看我的问题吗