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