Android chrome custom tags are not closed during redirection
I'm using the chrome custom tag to get the OAuth connection request about redirection from the custom tag I successfully redirected in the app. The only problem is still that the chrome custom tag won't close when the redirection stays on the stack
The code to start the URL in the custom tag is as follows
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()));
I tried to use "singletask" and "singleinstance" in the manifest file, but the problem still exists
If I only use the intention "flag_no_history", it will work. But I need to force the use of "flag_activity_new_task", because in some cases, such as deleting the token of a specific site, and we try to re verify the browser to crash on Android version 7.1, and we need to manually start the application again
Any help is appreciated
resolvent:
The same problem was encountered when trying to validate the OAuth provider. I used custom tag 25.3.1 and addflags instead of setflags to make the code work:
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));
}
// ...
}