Created
October 16, 2015 06:35
-
-
Save t-kashima/4a5e5a0bf1105e232a92 to your computer and use it in GitHub Desktop.
DownloadManagerで画像をダウンロードしてDownloadディレクトリに保存する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DownloadManager downLoadManager = (DownloadManager)getActivity().getSystemService(Context.DOWNLOAD_SERVICE); | |
DownloadManager.Request request = new DownloadManager.Request(imageUri); | |
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "image.png"); | |
File pathExternalPublicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); | |
pathExternalPublicDir.mkdirs(); | |
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); | |
request.allowScanningByMediaScanner(); | |
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI); | |
downLoadManager.enqueue(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment