开发者

How can we read pdf file directly in webview using url in the android emulator

开发者 https://www.devze.com 2023-03-16 23:00 出处:网络
I want to read pdf 开发者_如何学Gofile from url in the android emulator. I have done the following, but it is not working

I want to read pdf 开发者_如何学Gofile from url in the android emulator.

I have done the following, but it is not working

    WebView web1 =(WebView)findViewById(R.id.webview);
    web1.getSettings().setJavaScriptEnabled(true);
    web1.loadUrl("http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");

and

 Uri path = Uri.parse("http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(path, "application/pdf");      //Set data type
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);    

    try 
    {
        startActivity(intent);
    } 
    catch (ActivityNotFoundException e) 
    {
        Toast.makeText(this," pdf not found", 
            Toast.LENGTH_SHORT).show();
    }

But it is still not working.

please help me

thanks in advance.


try this code ::

WebView web1 =(WebView)findViewById(R.id.webview);  
web1.getSettings().setJavaScriptEnabled(true);  
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");
0

精彩评论

暂无评论...
验证码 换一张
取 消