Instagram intent of the error in webview?

Asked

Viewed 2,188 times

0

When I click open in the instagram app in my app. My webview gives the following error:

Web page not available

Unable to upload web page to address Intent://instagram.com/_u/hotelcolonialdosnobres/#Intent;package=com.instagram.androi;Scheme=https;end

net::ERR_UNKNOWN_URL_SCHEME

In my webview I have this responsible function

webView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        //  try{ url != null &&
        if (url.startsWith("http://www.hotelcolonialdosnobres.com/")) {
            view.loadUrl(url);
            return true;
        }
        if (url.startsWith("mailto:") ||url.startsWith("intent://") || url.startsWith("market://")  ){
            try {
                final   Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
           final  Activity host = (Activity) view.getContext();
            host.startActivity(intent);
            return true;
            }catch (ActivityNotFoundException e) {
                // Google Play app is not installed, you may want to open the app store link  uri.getQuery())
               // Uri uri = Uri.parse(url);
                view.loadUrl(url);
                return false;
            }
        }
        return false;
    }

});

How to troubleshoot this error so it can open ?

1 answer

1


You can solve the problem using the following code, works correctly to open links on Instagram right from your application.

Uri uri = Uri.parse("https://www.instagram.com/hotelcolonialdosnobres/");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

likeIng.setPackage("com.instagram.android");

try {
    startActivity(likeIng);
} catch (ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW,
    Uri.parse("https://www.instagram.com/hotelcolonialdosnobres/")));
}
  • But that code won’t work if I press to open facebook

Browser other questions tagged

You are not signed in. Login or sign up in order to post.