3
웹에있는 파일에 대한 링크가있는 앱이 있습니다. 사용자가 장치에 파일을 다운로드하도록 선택하면 파일이 자동으로 열리 길 원합니다. 다운로드가 완료된 후Android에서 다운로드 한 후 다운로드 한 파일 열기
private void downloadFile(String url) {
if (GeneralHelper.isNetworkAvailable(this)) {
Uri uri = Uri.parse(url);
DownloadManager.Request r = new DownloadManager.Request(uri);
String fileName = url.substring(url.lastIndexOf('/')+ 1, url.length());
// This put the download in the same Download dir the browser uses
r.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
r.allowScanningByMediaScanner();
// Notify user when download is completed
// (Seems to be available since Honeycomb only)
r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
// Start download
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(r);
}
else {
// ....
}
}
가 어떻게 파일을 열 수있는 코드를 추가 할 수 있습니다 이 다운로드에 대한 내 코드?
http://blog.vogella.com/2011/06/14/android-downloadmanager -example/ 잘 작동합니다. – srijanshukla