From 58af3557e846687d17ace088574b9a6b9b2633e0 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 22 Sep 2020 23:41:57 +0800 Subject: Support Chrome Custom Tabs in Android 11. --- .../Activity/LinkResolverActivity.java | 34 +++------------------- 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index 241d47a6..9706d015 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -271,40 +271,14 @@ public class LinkResolverActivity extends AppCompatActivity { Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show(); } } - - /*List activities = pm.queryIntentActivities(intent, 0); - ArrayList packageNames = new ArrayList<>(); - - String currentPackageName = getApplicationContext().getPackageName(); - - for (ResolveInfo info : activities) { - if (!info.activityInfo.packageName.equals(currentPackageName)) { - packageNames.add(info.activityInfo.packageName); - } - } - - if (!packageNames.isEmpty()) { - try { - startActivity(intent); - } catch (ActivityNotFoundException e) { - if (handleError) { - openInCustomTabs(uri, pm, false); - } else { - Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show(); - } - } - } else { - if (handleError) { - openInCustomTabs(uri, pm, false); - } else { - Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show(); - } - }*/ } private ArrayList getCustomTabsPackages(PackageManager pm) { // Get default VIEW intent handler. - Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.example.com")); + Intent activityIntent = new Intent() + .setAction(Intent.ACTION_VIEW) + .addCategory(Intent.CATEGORY_BROWSABLE) + .setData(Uri.fromParts("http", "", null)); // Get all apps that can handle VIEW intents. List resolvedActivityList = pm.queryIntentActivities(activityIntent, 0); -- cgit v1.2.3