Refine search
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link)); request.setDestinationUri(Uri.fromFile(file)); receiver.setDownloadId(downloadManager.enqueue(request));
@Test public void request_shouldGetNotificationVisibility() throws Exception { request.setNotificationVisibility(Request.VISIBILITY_VISIBLE); assertThat(shadow.getNotificationVisibility()).isEqualTo(Request.VISIBILITY_VISIBLE); }
request.setDescription(Main.this.getString(R.string.notification_description)); request.setTitle(Main.this.getString(R.string.app_name)); request.setDestinationUri(uri); final long downloadId = manager.enqueue(request); install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); install.setDataAndType(uri, manager.getMimeTypeForDownloadedFile(downloadId)); startActivity(install);
DownloadManager.Request localRequest = new DownloadManager.Request(Uri.parse(apkUrl)); localRequest.setDescription("Downloading " + getAppName() + " " + latestVersion); localRequest.setTitle(getAppName() + " Update"); localRequest.allowScanningByMediaScanner(); localRequest.setNotificationVisibility(1); Log.d(AppStarterUpdater.class.getName(), "Download to file://" + downloadFile.getAbsolutePath()); localRequest.setDestinationUri(Uri.parse("file://" + downloadFile.getAbsolutePath())); mQueueValue = mDownloadManager.enqueue(localRequest); Cursor cursor = mDownloadManager.query(q); int percentage = 0; if(cursor.moveToFirst())
@Test public void request_shouldGetMimeType() throws Exception { request.setMimeType("application/json"); assertThat(shadow.getMimeType()).isEqualTo("application/json"); }
@Test public void query_shouldReturnColumnValues() throws Exception { ShadowDownloadManager manager = new ShadowDownloadManager(); long id = manager.enqueue(request.setDestinationUri(destination)); Cursor cursor = manager.query(new DownloadManager.Query().setFilterById(id)); cursor.moveToNext(); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))).isEqualTo(uri.toString()); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).isEqualTo(destination.toString()); }
@Test public void request_shouldGetDestinationUri() throws Exception { request.setDestinationUri(Uri.parse("/storage/media/foo.mp4")); assertThat(shadow.getDestination().toString()).isEqualTo("/storage/media/foo.mp4"); }
@Test public void query_shouldReturnColumnIndexes() throws Exception { ShadowDownloadManager manager = new ShadowDownloadManager(); long id = manager.enqueue(request.setDestinationUri(destination)); Cursor cursor = manager.query(new DownloadManager.Query().setFilterById(id)); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_URI)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_REASON)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)).isAtLeast(0); }
@Test public void request_shouldGetDescription() throws Exception { request.setDescription("Description"); assertThat(shadow.getDescription()).isEqualTo("Description"); }
@Test public void request_shouldGetTitle() throws Exception { request.setTitle("Title"); assertThat(shadow.getTitle()).isEqualTo("Title"); }
@Test public void query_shouldReturnAll() { ShadowDownloadManager manager = new ShadowDownloadManager(); long firstId = manager.enqueue(request.setDestinationUri(destination)); Uri secondUri = Uri.parse("http://example.com/foo2.mp4"); Uri secondDestination = Uri.parse("file:///storage/foo2.mp4"); Request secondRequest = new Request(secondUri); long secondId = manager.enqueue(secondRequest.setDestinationUri(secondDestination)); Cursor cursor = manager.query(new DownloadManager.Query()); cursor.moveToNext(); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))).isEqualTo(uri.toString()); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).isEqualTo(destination.toString()); cursor.moveToNext(); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))).isEqualTo(secondUri.toString()); assertThat(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).isEqualTo(secondDestination.toString()); }
Uri downloadUri = Uri.parse(DOWNLOAD_FILE); DownloadManager.Request request = new DownloadManager.Request(downloadUri); request.setDescription("Downloading a file"); long id = downloadManager.enqueue(request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |DownloadManager.Request.NETWORK_MOBILE) .setAllowedOverRoaming(false) .setTitle("File Downloading...") .setDescription("Image File Download") .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "cm.png"));
// Changing the Notification Title, Description, and its Visibility DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); Uri uri = Uri.parse("///.mp3"); DownloadManager.Request req = DownloadManager.Request(uri); req.setTitle("Download"); req.setDescription("Kick Ass Description"); req.setVisibility(Request.VISIBILITY_VISIBLE_COMPLETION_ONLY);
private void downloadVideoFile(String vidUrl, String fileName) { File direct = new File(Environment.getExternalStorageDirectory() + FOLDER_DESTINATION); if (!direct.exists()) { direct.mkdirs(); } Uri srcUri = Uri.parse(vidUrl); DownloadManager.Request request = new DownloadManager.Request(srcUri); request.setDestinationInExternalPublicDir(FOLDER_DESTINATION, fileName); request.setDescription("Just for test"); request.setTitle("Test.mp4"); mDownloadManager.enqueue(request); }
Uri downloadUri = Uri.parse(DOWNLOAD_FILE); DownloadManager.Request request = new DownloadManager.Request(downloadUri); request.setDescription("Downloading a file"); long id = downloadManager.enqueue(request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |DownloadManager.Request.NETWORK_MOBILE) .setAllowedOverRoaming(false) .setTitle("File Downloading...") .setDescription("File Download Description") .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "test.png"));
Uri downloadUri = Uri.parse(DOWNLOAD_FILE); DownloadManager.Request request = new DownloadManager.Request(downloadUri); request.setDescription("Downloading a file"); long id = downloadManager.enqueue(request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |DownloadManager.Request.NETWORK_MOBILE) .setAllowedOverRoaming(false) .setTitle("File Downloading...") .setDescription("Image File Download") .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "cm.png"));
public void downloadImage(){ // Un-registering the receiver unregisterReceiver(receiver); myDownloadManager(); dm = (DownloadManager) getActivity().getSystemService(getActivity().DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse("some uri")); request.setDestinationInExternalPublicDir("some directory", name); enqueue = dm.enqueue(request); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videoview); myDownloadManager(); } public void downloadImage(){ dm = (DownloadManager) getActivity().getSystemService(getActivity().DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse("some uri")); request.setDestinationInExternalPublicDir("some directory", name); enqueue = dm.enqueue(request); }
File folder = new File(Environment.getExternalStorageDirectory() + "/any"); if (!folder.exists()) { folder.mkdir(); } DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setDestinationInExternalPublicDir("/Download/Global Mp3", nameOfFile);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setTitle("Some title");