1

I am loading a URL in WebView. URL goes through proxy so it asks for login then let me through page . Next time when i try same url then it gives ERR_CONNECTION_TIMED_OUT as i have already login for that URL.

Even using CookieManger.getInstance().acceptCookie() does not help. What i am doing:

WebViewClient wvc = new WebViewClient() {

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        //progressBar.setVisibility(View.INVISIBLE);
        super.onPageStarted(view, url, favicon);
    }

    public void onPageFinished(WebView view, String url) {
        isLoaded = true;
        progressBar.setVisibility(View.INVISIBLE);


    }

    @Override
    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
        progressBar.setVisibility(View.INVISIBLE);
        super.onReceivedError(view, request, error);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView wView, String url) {
        progressBar.setVisibility(View.INVISIBLE);
        Log.d(getClass().getSimpleName(), "loading url: " + url);
        if(!isHomeUrlLoaded) {
           // webView.loadUrl(url);
            return false;

        } else {
            openCustomTab(url);
        }
        return true;
    }
};

private void openCustomTab(String url) {
    PackageManager manager = getActivity().getPackageManager();
    try {
        PackageInfo packageInfo = manager.getPackageInfo("com.android.chrome", PackageManager.GET_ACTIVITIES);
        String packageVersion = packageInfo.versionName;
        //packageVersion = "52.0.2623.105";
        Log.d(sTag, "Chrome version code :" + packageVersion);
        if(packageVersion.compareTo("44") >= 1) {
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.intent.setPackage("com.android.chrome");
            customTabsIntent.launchUrl(getActivity(), Uri.parse(url));
        } else {
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            i.setPackage("com.android.chrome");
            startActivity(i);
        };
    } catch (PackageManager.NameNotFoundException e) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        startActivity(i);
    } catch (Exception e) {

    }
}

Any help is appreciated.

  • Please refer this link it may help you http://stackoverflow.com/questions/6673159/android-webview-internet-access-problem-because-of-proxy – Vijayaramanan Aug 25 '16 at 21:28
  • tried did not work WebView.enablePlatformNotifications() is deperecated and always enabled in latest versions – Anurag Sharma Aug 26 '16 at 05:36

0 Answers0