Answer
Saad
Online
5/24/2012 3:44:01 PM
Hi, One approach is to install the quick office in the mobile phone and use the following code to view the pdf file.
public class Pdf extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.PdfButton); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File file = new File("/sdcard/myfile.pdf");
if (file.exists()) { Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try { startActivity(intent); } catch (ActivityNotFoundException e) { // "No Application to View PDF", } } } }); } }
Second you can use PDFBOX api to read the pdf files in android. Search on google you will find it
|
Answer
thanks for your reply :D but i still can't run this application.. there's still error on Button button = (Button) findViewById(R.id.PdfButton); button.setOnClickListener(new View.OnClickListener() { maybe u can tell me, what should i add..? sorry i bother you, but i still newbie :(
|
Answer
Saad
Online
6/1/2012 2:10:43 PM
Can you please paste the error here. Just write the try catch block around your code and check the exception message. Also paste that message here.
|
Answer
List is a raw type. References to generic type List should be parameterized readeractivity.java /reader/src/reader/com line 19 Java Problem
or maybe i must make a button in main.xml..? if yes i already make it, and no error again.. but the pdf file still not show, can i send u my android project?
|
Answer
Saad
Online
6/6/2012 2:32:44 PM
Please attach the debugger with your code, then run your project and check which line throws the error.
|
Answer
i'm sorry but i don't understand how to check error.. and i dont understand english too much :( but thanks a lot for your help :D
|