[Android] android 파일 다운로드 후 hwp파일 열기!
프로그래밍/Android2015. 3. 26. 11:25
다른 블로그들 참고하는데 안되다가 되는 블로그 발견!
file = File 클래스 변수임(안나와있는데 대충 File클래스 메소드를 사용하길래 해당 자료형의 변수로 선언했더니 잘됨.
참고로 파일에 해당하는 뷰어나 볼 수 있는 프로그램이 있어야됨.
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{
try{
startActivity(intent);
}catch(ActivityNotFoundException e){
util.showLongToast("해당파일을 실항할 수 있는 어플리케이션이 없습니다.\n파일을 열 수 없습니다.");
e.printStackTrace();
}
pdf = "application/pdf"
jpg 등 = "image/*"
docx = "application/msword"
txt = "text"
pptx = "application/vnd.ms-powerpoint"
hwp = "application/haansofthwp"
mp3 = "audio/*"
mp4 = "video/*"
...
mineType 안헷갈리게 조심!
'프로그래밍 > Android' 카테고리의 다른 글
[Android] Android 기기 현재 해상도 가져오기 (0) | 2015.04.01 |
---|---|
[Android] WebView(웹뷰) 속성 (0) | 2015.03.26 |
[Android] XML 파일 생성 (0) | 2015.03.18 |
[Android] if 값 비교가 제대로 안되는 경우 ex: if(a == b) (0) | 2015.03.16 |
[Android] Android 기본탐색기가 없다!! (0) | 2015.01.23 |