0
서버에서 파일을 다운로드하고 다양한 파일로 안드로이드에서 파일을보고 싶습니다. 같은 (PDF, 문서, MP4, JPEG) 내가이서버에서 파일을 다운로드하고 다양한 파일을 포함한 안드로이드에서 파일을보고 싶습니다. (pdf, doc, mp4, jpeg)와 같은 확장자)
서버에서 파일을 다운로드하고 다양한 파일로 안드로이드에서 파일을보고 싶습니다. 같은 (PDF, 문서, MP4, JPEG) 내가이서버에서 파일을 다운로드하고 다양한 파일을 포함한 안드로이드에서 파일을보고 싶습니다. (pdf, doc, mp4, jpeg)와 같은 확장자)
이 참조 해결하는 방법을 제안 해주십시오 내가이 의 개별 확장을 제공해야한다이
Intent intent = new Intent(Intent.ACTION_VIEW);
File file1 = new File(Environment.getExternalStorageDirectory(),"report.pdf");
intent.setDataAndType(Uri.fromFile(file1), "application/.*");
startActivity(intent);
하지만 성공을 시도해야 참조 용 코드
filePath는 파일의 실제 경로입니다
Uri fileUri = Uri.fromFile(new File(filePath));
Uri new_uri = Uri.parse("file://"
+ fileUri.getPath());
Intent intent = new Intent(Intent.ACTION_VIEW,
new_uri);
MimeTypeMap myMime = MimeTypeMap.getSingleton();
String fileExt = filePath.substring(filePath
.lastIndexOf(".") + 1);
String mimeType = myMime
.getMimeTypeFromExtension(fileExt);
intent.setDataAndType(new_uri, mimeType);
startActivity(intent);
해결책 주셔서 감사합니다 ... – user3312537