1. Download our Official Android App: Forums for Android!

Apps Webview PDF issue

Discussion in 'Android Development' started by amy97, Mar 22, 2011.

  1. amy97

    amy97 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    9
    Joined:
    Mar 1, 2011

    Mar 1, 2011
    9
    0
    5
    Hi,

    I am seeing one strange issue for PDF download in webview:If I Override
    shouldOverrideUrlLoading() for webview client then PDF file is not getting downloaded for embedded URL in webview.
    But without its working fine.I am overriding above method to avoid authentication page pop up within same webview for embedded URL when user click it on this.
    Can you please let me know how to resolve this issue:I have posted code below for both scenraios.

    Thanks in advance..
    Case I code below (able to download pdf file):
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.titledetails);

    Bundle bundle = getIntent().getExtras();
    String body = bundle.getString("title");

    webview = (WebView) findViewById(R.id.webview);


    webview.getSettings().setJavaScriptEnabled(true);
    //webview.l
    webview.loadDataWithBaseURL(null, body, "text/html", "utf-8","");

    }

    Case 2 (not able to download pdf file)

    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.titledetails);

    Bundle bundle = getIntent().getExtras();
    String body = bundle.getString("title");

    webview = (WebView) findViewById(R.id.webview);


    webview.setWebChromeClient(chromeClient);
    webview.setWebViewClient(wvClient);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setPluginsEnabled(true);
    webview.setWebViewClient(new WebViewClient()
    {

    // @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {



    view.loadUrl(url);



    return true;
    }

    });



    webview.getSettings().setJavaScriptEnabled(true);

    webview.loadDataWithBaseURL(null, body, "text/html", "utf-8","");

    }

    PS.As I did not get any response reposting same thread...

    Thanks,
    Amy
     

    Advertisement

Share This Page

Loading...