Error Instagram Intent in webview?

0

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

  

Web page not available

     

Could not load webpage at address   try: //instagram.com/_u/hotelcolonialdosnobres/#Intent; package = com.instagram.androi; scheme = https; end

     

net :: ERR_UNKNOWN_URL_SCHEME

In my webview I have this responsible role

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 fix this error so that it can open?

    
asked by anonymous 28.10.2016 / 11:00

1 answer

1

You can solve the problem by using the following code, it works correctly to open links in 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/")));
}
    
28.10.2016 / 13:19