본문 바로가기
IT 개발

[Android 개발팁] 파일 다운로드 후 pdf파일 또는 hwp파일 열기.

by 로보찌빠냥 2011. 3. 15.
반응형

  Intent intent = new Intent();
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setAction(android.content.Intent.ACTION_VIEW);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  if (file.getName().endsWith(".pdf")){
 intent.setDataAndType(Uri.fromFile(file), "application/pdf");
  }else if (file.getName().endsWith(".hwp")){
intent.setDataAndType(Uri.fromFile(file), "application/hwp");
  }
  try{
   startActivity(intent);
  }catch(ActivityNotFoundException e){
   util.showLongToast("해당파일을 실항할 수 있는 어플리케이션이 없습니다.\n파일을 열 수 없습니다.");
   e.printStackTrace();
  }


반응형

댓글