KindleとAndroid用に作成しているアプリにWebサイトからPDFを開きたいです。
私のコードは正しいと思いますが、ファイルが見つからず、技術的にはWebサイトであるため、ファイルを別の形式にする必要があるかどうかを誰かが知っているかどうかわかりませんでした。
任意の入力をいただければ幸いです。これが私がこれまでに持っているものです:
Button OpenPDF = (Button) findViewById(R.id.button1);
OpenPDF.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
File pdfFile = new File("http://thisisthewebsitewithpdf.pdf");
if(pdfFile.exists()) //EXCEPTION HERE. pdfFile doesn't exist!
{
Uri path = Uri.fromFile(pdfFile);
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(pdfIntent);
}
catch(ActivityNotFoundException e)
{
Toast.makeText(PDFActivity.this, "No Application available to view pdf", Toast.LENGTH_LONG).show();
}
}