Showing Pdf file link in the webview

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Showing Pdf file link in the webview

Postby munireddy » Mon Dec 28, 2009 6:29 pm

Hi

I have a pdf file link ( http://74.54.60.18:2244/responseletters/Test_PDF3.pdf ) in the response given by the .net web service. And I need to display that pdf file in the web view.
Could any one give me the solution...urgent...

Thanks in advance.....
munireddy
Developer
Developer
 
Posts: 28
Joined: Mon Dec 28, 2009 5:47 pm
Location: MOHALI

Top

Postby munireddy » Fri Jan 15, 2010 6:39 pm

Hi

Still I am waiting for the correct response :(

I have implemented this in different way... I have got the pdf link from the response ( http://74.54.60.18:2244/responseletters/Test_PDF3.pdf )..and i have set this link text to the text view which is
android:autoLink="web" in the lay out xml file.
And user have to click the link to download the pdf file ( it is showing the web link in the next screen).

But my requirement is when the user clicks on the button it should show pdf file directly in the webview.


Could any body help me out in this.

Thank you in advance...
munireddy
Developer
Developer
 
Posts: 28
Joined: Mon Dec 28, 2009 5:47 pm
Location: MOHALI

Postby pranav09 » Thu Apr 15, 2010 7:41 am

Hi munireddy,

I know it's too late but i read this post late.

By the way, if i am not wrong, you want to show the the ".pdf" file directly in the web view on the click of the button. For that, i tried to do same thing and i found the solution. Just follow the below code.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. // Organized imports...
  3.  
  4.  
  5.  
  6. public class WebViewDemo extends Activity
  7.  
  8.  
  9.  
  10. {
  11.  
  12.         Button b;
  13.  
  14.         WebView wv;
  15.  
  16.        
  17.  
  18.     @Override
  19.  
  20.     public void onCreate(Bundle savedInstanceState) {
  21.  
  22.         super.onCreate(savedInstanceState);
  23.  
  24.         setContentView(R.layout.main);
  25.  
  26.  
  27.  
  28.         wv = (WebView) findViewById(R.id.wv1);
  29.  
  30.         b = (Button)findViewById(R.id.btn);
  31.  
  32.         b.setOnClickListener(new View.OnClickListener()
  33.  
  34.         {
  35.  
  36.                         @Override
  37.  
  38.                         public void onClick(View v)
  39.  
  40.                         {
  41.  
  42.                                 wv.loadUrl("http://74.54.60.18:2244/responseletters/Test_PDF3.pdf");
  43.  
  44.                         }
  45.  
  46.                 });
  47.  
  48.     }
  49.  
  50. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Hope, it's help you.

Thanks.
______________
Pranav
User avatar
pranav09
Senior Developer
Senior Developer
 
Posts: 128
Joined: Mon Jan 19, 2009 12:01 pm
Location: Ahmedabad, India

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 9 guests