我打开带有chrome自定义标签的网址,并在标签中导航。现在,我想关闭自定义标签并返回到原始应用程序,但是仅在返回所有应用程序历史记录后,设备后退按钮才会关闭。我想使用设备后退按钮关闭自定义标签,而忽略标签中的所有历史记录。这在功能上可行吗?
String url = eacharticle.get("url");
String PACKAGE_NAME = "com.android.chrome";
android.support.customtabs.CustomTabsIntent customTabsIntent = new android.support.customtabs.CustomTabsIntent.Builder().setShowTitle(true).build();
customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
customTabsIntent.intent.setData(Uri.parse(url));
java.util.List<android.content.pm.ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(customTabsIntent.intent, android.content.pm.PackageManager.MATCH_DEFAULT_ONLY);
for (android.content.pm.ResolveInfo resolveInfo : resolveInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
if(PACKAGE_NAME.equals(packageName))
customTabsIntent.intent.setPackage(PACKAGE_NAME); // force use chrome if installed
}
customTabsIntent.launchUrl(context, Uri.parse(url));