{"action":"created","comment":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments/60909874","id":60909874,"diff_hunk":"@@ -1485,8 +1488,48 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {\n                     mFlipCardLayout.setVisibility(View.GONE);\n                     return true;\n                 }\n-                Timber.d(\"Opening external link \\\"%s\\\" with an Intent\", url);\n-                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));\n+                Intent intent = null;\n+                try {\n+                    if (url.startsWith(\"intent:\")) {\n+                        intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);\n+                    } else if (url.startsWith(\"android-app:\")) {\n+                        intent = Intent.parseUri(url, Intent.URI_ANDROID_APP_SCHEME); // note - also works pre-22\n+                    }\n+                    if (intent != null) {\n+                        if (getPackageManager().resolveActivity(intent, 0) == null) {\n+                            String fallbackUrl = intent.getStringExtra(EXTRA_BROWSER_FALLBACK_URL);\n+                            if (!TextUtils.isEmpty(fallbackUrl)) {\n+                                Timber.d(\"Using fallback url in intent uri: %s\", url);\n+                                intent = null; // open it the same way as other urls\n+                                url = fallbackUrl;\n+                            } else {\n+                                String packageName = intent.getPackage();\n+                                if (packageName == null) {\n+                                    Timber.d(\"Not using resolved intent uri because not available: %s\", intent);\n+                                    intent = null;\n+                                } else {\n+                                    Timber.d(\"Resolving intent uri to market uri because not available: %s\", intent);\n+                                    intent = new Intent(Intent.ACTION_VIEW,\n+                                            Uri.parse(\"market://details?id=\" + packageName));\n+                                    if (getPackageManager().resolveActivity(intent, 0) == null) {\n+                                        intent = null;\n+                                    }\n+                                }\n+                            }\n+                        } else {\n+                            // https://developer.chrome.com/multidevice/android/intents says that we should remove this\n+                            intent.removeExtra(EXTRA_BROWSER_FALLBACK_URL);","path":"AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java","position":60,"original_position":60,"commit_id":"e3de2d187702954d62f4cf965c6d11bf6a8118f5","original_commit_id":"e3de2d187702954d62f4cf965c6d11bf6a8118f5","user":{"login":"marcardar","id":409640,"avatar_url":"https://avatars.githubusercontent.com/u/409640?v=3","gravatar_id":"","url":"https://api.github.com/users/marcardar","html_url":"https://github.com/marcardar","followers_url":"https://api.github.com/users/marcardar/followers","following_url":"https://api.github.com/users/marcardar/following{/other_user}","gists_url":"https://api.github.com/users/marcardar/gists{/gist_id}","starred_url":"https://api.github.com/users/marcardar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcardar/subscriptions","organizations_url":"https://api.github.com/users/marcardar/orgs","repos_url":"https://api.github.com/users/marcardar/repos","events_url":"https://api.github.com/users/marcardar/events{/privacy}","received_events_url":"https://api.github.com/users/marcardar/received_events","type":"User","site_admin":false},"body":"Should we add the `Intent.CATEGORY_BROWSABLE` here?","created_at":"2016-04-25T13:14:14Z","updated_at":"2016-04-25T13:14:14Z","html_url":"https://github.com/ankidroid/Anki-Android/pull/4229#discussion_r60909874","pull_request_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229","_links":{"self":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments/60909874"},"html":{"href":"https://github.com/ankidroid/Anki-Android/pull/4229#discussion_r60909874"},"pull_request":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229"}}},"pull_request":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229","id":67610217,"html_url":"https://github.com/ankidroid/Anki-Android/pull/4229","diff_url":"https://github.com/ankidroid/Anki-Android/pull/4229.diff","patch_url":"https://github.com/ankidroid/Anki-Android/pull/4229.patch","issue_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/4229","number":4229,"state":"open","locked":false,"title":"Support intent: and android-app: url schemes in templates","user":{"login":"marcardar","id":409640,"avatar_url":"https://avatars.githubusercontent.com/u/409640?v=3","gravatar_id":"","url":"https://api.github.com/users/marcardar","html_url":"https://github.com/marcardar","followers_url":"https://api.github.com/users/marcardar/followers","following_url":"https://api.github.com/users/marcardar/following{/other_user}","gists_url":"https://api.github.com/users/marcardar/gists{/gist_id}","starred_url":"https://api.github.com/users/marcardar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcardar/subscriptions","organizations_url":"https://api.github.com/users/marcardar/orgs","repos_url":"https://api.github.com/users/marcardar/repos","events_url":"https://api.github.com/users/marcardar/events{/privacy}","received_events_url":"https://api.github.com/users/marcardar/received_events","type":"User","site_admin":false},"body":"Following on from [this discussion](https://groups.google.com/forum/#!topic/anki-android/UDKasC1fEAw).","created_at":"2016-04-23T15:47:37Z","updated_at":"2016-04-25T13:14:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"22bba5f98f2e9e09e0fd46222fc34d51408e391d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229/commits","review_comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229/comments","review_comment_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/4229/comments","statuses_url":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/e3de2d187702954d62f4cf965c6d11bf6a8118f5","head":{"label":"marcardar:support-intent-url-schemes","ref":"support-intent-url-schemes","sha":"e3de2d187702954d62f4cf965c6d11bf6a8118f5","user":{"login":"marcardar","id":409640,"avatar_url":"https://avatars.githubusercontent.com/u/409640?v=3","gravatar_id":"","url":"https://api.github.com/users/marcardar","html_url":"https://github.com/marcardar","followers_url":"https://api.github.com/users/marcardar/followers","following_url":"https://api.github.com/users/marcardar/following{/other_user}","gists_url":"https://api.github.com/users/marcardar/gists{/gist_id}","starred_url":"https://api.github.com/users/marcardar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcardar/subscriptions","organizations_url":"https://api.github.com/users/marcardar/orgs","repos_url":"https://api.github.com/users/marcardar/repos","events_url":"https://api.github.com/users/marcardar/events{/privacy}","received_events_url":"https://api.github.com/users/marcardar/received_events","type":"User","site_admin":false},"repo":{"id":52933751,"name":"Anki-Android","full_name":"marcardar/Anki-Android","owner":{"login":"marcardar","id":409640,"avatar_url":"https://avatars.githubusercontent.com/u/409640?v=3","gravatar_id":"","url":"https://api.github.com/users/marcardar","html_url":"https://github.com/marcardar","followers_url":"https://api.github.com/users/marcardar/followers","following_url":"https://api.github.com/users/marcardar/following{/other_user}","gists_url":"https://api.github.com/users/marcardar/gists{/gist_id}","starred_url":"https://api.github.com/users/marcardar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcardar/subscriptions","organizations_url":"https://api.github.com/users/marcardar/orgs","repos_url":"https://api.github.com/users/marcardar/repos","events_url":"https://api.github.com/users/marcardar/events{/privacy}","received_events_url":"https://api.github.com/users/marcardar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marcardar/Anki-Android","description":"AnkiDroid: Anki on Android","fork":true,"url":"https://api.github.com/repos/marcardar/Anki-Android","forks_url":"https://api.github.com/repos/marcardar/Anki-Android/forks","keys_url":"https://api.github.com/repos/marcardar/Anki-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marcardar/Anki-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marcardar/Anki-Android/teams","hooks_url":"https://api.github.com/repos/marcardar/Anki-Android/hooks","issue_events_url":"https://api.github.com/repos/marcardar/Anki-Android/issues/events{/number}","events_url":"https://api.github.com/repos/marcardar/Anki-Android/events","assignees_url":"https://api.github.com/repos/marcardar/Anki-Android/assignees{/user}","branches_url":"https://api.github.com/repos/marcardar/Anki-Android/branches{/branch}","tags_url":"https://api.github.com/repos/marcardar/Anki-Android/tags","blobs_url":"https://api.github.com/repos/marcardar/Anki-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marcardar/Anki-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marcardar/Anki-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/marcardar/Anki-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marcardar/Anki-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/marcardar/Anki-Android/languages","stargazers_url":"https://api.github.com/repos/marcardar/Anki-Android/stargazers","contributors_url":"https://api.github.com/repos/marcardar/Anki-Android/contributors","subscribers_url":"https://api.github.com/repos/marcardar/Anki-Android/subscribers","subscription_url":"https://api.github.com/repos/marcardar/Anki-Android/subscription","commits_url":"https://api.github.com/repos/marcardar/Anki-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/marcardar/Anki-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/marcardar/Anki-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/marcardar/Anki-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/marcardar/Anki-Android/contents/{+path}","compare_url":"https://api.github.com/repos/marcardar/Anki-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marcardar/Anki-Android/merges","archive_url":"https://api.github.com/repos/marcardar/Anki-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marcardar/Anki-Android/downloads","issues_url":"https://api.github.com/repos/marcardar/Anki-Android/issues{/number}","pulls_url":"https://api.github.com/repos/marcardar/Anki-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/marcardar/Anki-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/marcardar/Anki-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marcardar/Anki-Android/labels{/name}","releases_url":"https://api.github.com/repos/marcardar/Anki-Android/releases{/id}","deployments_url":"https://api.github.com/repos/marcardar/Anki-Android/deployments","created_at":"2016-03-02T04:26:22Z","updated_at":"2016-03-02T04:26:27Z","pushed_at":"2016-04-25T09:32:08Z","git_url":"git://github.com/marcardar/Anki-Android.git","ssh_url":"git@github.com:marcardar/Anki-Android.git","clone_url":"https://github.com/marcardar/Anki-Android.git","svn_url":"https://github.com/marcardar/Anki-Android","homepage":"","size":103750,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ankidroid:develop","ref":"develop","sha":"fae810ea230ec0f0d6948baf083441dc48a40038","user":{"login":"ankidroid","id":3320903,"avatar_url":"https://avatars.githubusercontent.com/u/3320903?v=3","gravatar_id":"","url":"https://api.github.com/users/ankidroid","html_url":"https://github.com/ankidroid","followers_url":"https://api.github.com/users/ankidroid/followers","following_url":"https://api.github.com/users/ankidroid/following{/other_user}","gists_url":"https://api.github.com/users/ankidroid/gists{/gist_id}","starred_url":"https://api.github.com/users/ankidroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankidroid/subscriptions","organizations_url":"https://api.github.com/users/ankidroid/orgs","repos_url":"https://api.github.com/users/ankidroid/repos","events_url":"https://api.github.com/users/ankidroid/events{/privacy}","received_events_url":"https://api.github.com/users/ankidroid/received_events","type":"Organization","site_admin":false},"repo":{"id":7716883,"name":"Anki-Android","full_name":"ankidroid/Anki-Android","owner":{"login":"ankidroid","id":3320903,"avatar_url":"https://avatars.githubusercontent.com/u/3320903?v=3","gravatar_id":"","url":"https://api.github.com/users/ankidroid","html_url":"https://github.com/ankidroid","followers_url":"https://api.github.com/users/ankidroid/followers","following_url":"https://api.github.com/users/ankidroid/following{/other_user}","gists_url":"https://api.github.com/users/ankidroid/gists{/gist_id}","starred_url":"https://api.github.com/users/ankidroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankidroid/subscriptions","organizations_url":"https://api.github.com/users/ankidroid/orgs","repos_url":"https://api.github.com/users/ankidroid/repos","events_url":"https://api.github.com/users/ankidroid/events{/privacy}","received_events_url":"https://api.github.com/users/ankidroid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ankidroid/Anki-Android","description":"AnkiDroid: Anki on Android","fork":false,"url":"https://api.github.com/repos/ankidroid/Anki-Android","forks_url":"https://api.github.com/repos/ankidroid/Anki-Android/forks","keys_url":"https://api.github.com/repos/ankidroid/Anki-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ankidroid/Anki-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ankidroid/Anki-Android/teams","hooks_url":"https://api.github.com/repos/ankidroid/Anki-Android/hooks","issue_events_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/events{/number}","events_url":"https://api.github.com/repos/ankidroid/Anki-Android/events","assignees_url":"https://api.github.com/repos/ankidroid/Anki-Android/assignees{/user}","branches_url":"https://api.github.com/repos/ankidroid/Anki-Android/branches{/branch}","tags_url":"https://api.github.com/repos/ankidroid/Anki-Android/tags","blobs_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/ankidroid/Anki-Android/languages","stargazers_url":"https://api.github.com/repos/ankidroid/Anki-Android/stargazers","contributors_url":"https://api.github.com/repos/ankidroid/Anki-Android/contributors","subscribers_url":"https://api.github.com/repos/ankidroid/Anki-Android/subscribers","subscription_url":"https://api.github.com/repos/ankidroid/Anki-Android/subscription","commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/ankidroid/Anki-Android/contents/{+path}","compare_url":"https://api.github.com/repos/ankidroid/Anki-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ankidroid/Anki-Android/merges","archive_url":"https://api.github.com/repos/ankidroid/Anki-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ankidroid/Anki-Android/downloads","issues_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues{/number}","pulls_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/ankidroid/Anki-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/ankidroid/Anki-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ankidroid/Anki-Android/labels{/name}","releases_url":"https://api.github.com/repos/ankidroid/Anki-Android/releases{/id}","deployments_url":"https://api.github.com/repos/ankidroid/Anki-Android/deployments","created_at":"2013-01-20T13:55:53Z","updated_at":"2016-04-22T18:10:22Z","pushed_at":"2016-04-25T11:41:39Z","git_url":"git://github.com/ankidroid/Anki-Android.git","ssh_url":"git@github.com:ankidroid/Anki-Android.git","clone_url":"https://github.com/ankidroid/Anki-Android.git","svn_url":"https://github.com/ankidroid/Anki-Android","homepage":"","size":125882,"stargazers_count":542,"watchers_count":542,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":422,"mirror_url":null,"open_issues_count":286,"forks":422,"open_issues":286,"watchers":542,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229"},"html":{"href":"https://github.com/ankidroid/Anki-Android/pull/4229"},"issue":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/issues/4229"},"comments":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/issues/4229/comments"},"review_comments":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229/comments"},"review_comment":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/4229/commits"},"statuses":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/e3de2d187702954d62f4cf965c6d11bf6a8118f5"}}}}