当前位置: 代码迷 >> Android >> 怎样显示assets目录下的pdf文件解决方案
  详细解决方案

怎样显示assets目录下的pdf文件解决方案

热度:85   发布时间:2016-05-01 21:41:53.0
怎样显示assets目录下的pdf文件
想把一个pdf文件放在assets目录下
使用Intent把pdf文件地址发送给adobereader
adobereader显示这个pdf.

已经实现读sdcard中的PDF文件显示
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Intent intent=getPdfFileIntent("/sdcard/A350.pdf");
  try {
  startActivity(intent);
  }  
  catch (ActivityNotFoundException e) {
  Toast.makeText(this,R.string.NO_PDF_READER_TIP,Toast.LENGTH_SHORT).show();
  }
  }

  public static Intent getPdfFileIntent(String param)
  {
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.addCategory("android.intent.category.DEFAULT");
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  Uri localUri = Uri.fromFile(new File(param));
  intent.setDataAndType(localUri, "application/pdf");
  return intent;
  }

------解决方案--------------------
Intent intent=getPdfFileIntent("file:///android_asset/test/test.pdf");
------解决方案--------------------
你的文件不能直接让其他程序读取,看看短信的分享
  相关解决方案