You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by julio cesar sanchez <jc...@gmail.com> on 2015/04/03 01:07:08 UTC
[proposal] [ANDROID] move inAppBrowser intents from onPageStarted to shouldOverrideUrlLoading
I've been looking into issues and I have seen this one:
https://issues.apache.org/jira/browse/CB-8180
Right now the code to handle the tel links is inside the onPageStarted
if (url.startsWith(WebView.SCHEME_TEL)) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, "Error dialing " + url + ": " +
e.toString());
}
}
But the problem is, it launchs the intent and try to open the web page, so
when you come back from the intent you see a "couldn't load the url" page
on the app.
I've tried to use the view.stopLoading() but it doesn't seem to stop it.
The issue only talks about the tel links, but I suppose that will happen
with sms, mailto and some other links.
So, I think a solution might be to move that code to
shouldOverrideUrlLoading function.
Is there any reason of doing this on the onPageStarted instead of using the
shouldOverrideUrlLoading?
Re: [proposal] [ANDROID] move inAppBrowser intents from onPageStarted
to shouldOverrideUrlLoading
Posted by Andrew Grieve <ag...@chromium.org>.
shouldOverrideUrlLoading is what the main cordova webview uses, so that's
certainly the right approach. I believe it should also add
CATEGORY_BROWSABLE to the intent to ensure that the user is prompted to
confirm whether they actually want to make the call.
On Thu, Apr 2, 2015 at 7:07 PM, julio cesar sanchez <jc...@gmail.com>
wrote:
> I've been looking into issues and I have seen this one:
> https://issues.apache.org/jira/browse/CB-8180
>
> Right now the code to handle the tel links is inside the onPageStarted
>
> if (url.startsWith(WebView.SCHEME_TEL)) {
> try {
> Intent intent = new Intent(Intent.ACTION_DIAL);
> intent.setData(Uri.parse(url));
> cordova.getActivity().startActivity(intent);
> } catch (android.content.ActivityNotFoundException e) {
> LOG.e(LOG_TAG, "Error dialing " + url + ": " +
> e.toString());
> }
> }
>
> But the problem is, it launchs the intent and try to open the web page, so
> when you come back from the intent you see a "couldn't load the url" page
> on the app.
>
> I've tried to use the view.stopLoading() but it doesn't seem to stop it.
> The issue only talks about the tel links, but I suppose that will happen
> with sms, mailto and some other links.
>
>
> So, I think a solution might be to move that code to
> shouldOverrideUrlLoading function.
>
> Is there any reason of doing this on the onPageStarted instead of using the
> shouldOverrideUrlLoading?
>