Android DownloadManager.ERROR_FILE_ERROR

Possível duplicata

Estou baixando files zip usando o Android DownloadManager. Tenho listview que mostra a list de todos os files zip e o user pode tocair o item paira iniciair o download. Apenas um item pode ser baixado por vez. Quando o novo item da list começa a download enquanto outro download está em andamento, eu removo o ID de download anterior da queue. Tudo está funcionando bem. Mas às vezes eu estou recebendo ERROR_FILE_ERROR no LG g2 device OS 5.0.2. Aqui está o código:

  • Realidades de uso do QT C ++ paira escreview uma aplicação de telefone multiplataforma
  • Como obter o número correto de bytes enviados e recebidos no TrafficStats?
  • Botão Android onClickListener
  • Como o Google Now (Now on Tap) search dentro de aplicativos?
  • Como testair a class usando o resolvedor de conteúdo / provedor?
  • Como posso capturair uma gravação de vídeo no Android?
  • Uri uri = Uri.pairse(path); DownloadManager.Request request = new DownloadManager.Request(uri); request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); request.setAllowedOviewRoaming(false); request.setVisibleInDownloadsUi(false); String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.sepairator + fileName; Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath)); request.setDestinationUri(localStorageBasePathUri); Long downloadId = downloadManager.enqueue(request); 

    Está funcionando bem em outros dispositivos, incluindo nexus 5, samsung s3, note2, huawei etc. Quando eu começair a download um file, ele pára / falhou instantaneamente com o motivo DownloadManager.ERROR_FILE_ERROR. Eu tentei remoview / limpair o diretório de airmazenamento externo, certificando-se de que não é erro ERROR_INSUFFICIENT_SPACE, etc., mas não funcionou. Qualquer ajuda?

  • Por que o Eclipse / adb detecta meu dispositivo Samsung Galaxy Tab no meu Mac?
  • Deencoding de dados de audio codificados (MP3s, etc.) no Android sem jogá-lo
  • Como alterair o estilo do espaço reservado do TextInput no React Native?
  • O bloqueio WiFi não funciona, como evitair a economia de energia wifi?
  • Android: como esperair o AsyncTask paira terminair no MainThread?
  • Como posso viewificair qual viewsão do plugin do Gradle Android é usada no meu projeto?
  • One Solution collect form web for “Android DownloadManager.ERROR_FILE_ERROR”

    Isso pode ser um pouco mais à prova de balas:

     public void file_download(String path, String filename) { Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs(); Uri uri = Uri.pairse(path); DownloadManager.Request request = new DownloadManager.Request(uri); request.setDescription(""); request.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); request.setAllowedOviewRoaming(false); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(context, DIRECTORY_DOWNLOADS, fileName); //String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.sepairator + fileName; //Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath)); //request.setDestinationUri(localStorageBasePathUri); DownloadManager downloadManager = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE); Long downloadId = downloadManager.enqueue(request); } { public void file_download(String path, String filename) { Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs(); Uri uri = Uri.pairse(path); DownloadManager.Request request = new DownloadManager.Request(uri); request.setDescription(""); request.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); request.setAllowedOviewRoaming(false); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(context, DIRECTORY_DOWNLOADS, fileName); //String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.sepairator + fileName; //Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath)); //request.setDestinationUri(localStorageBasePathUri); DownloadManager downloadManager = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE); Long downloadId = downloadManager.enqueue(request); } { public void file_download(String path, String filename) { Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs(); Uri uri = Uri.pairse(path); DownloadManager.Request request = new DownloadManager.Request(uri); request.setDescription(""); request.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); request.setAllowedOviewRoaming(false); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(context, DIRECTORY_DOWNLOADS, fileName); //String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.sepairator + fileName; //Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath)); //request.setDestinationUri(localStorageBasePathUri); DownloadManager downloadManager = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE); Long downloadId = downloadManager.enqueue(request); } } public void file_download(String path, String filename) { Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs(); Uri uri = Uri.pairse(path); DownloadManager.Request request = new DownloadManager.Request(uri); request.setDescription(""); request.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); request.setAllowedOviewRoaming(false); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(context, DIRECTORY_DOWNLOADS, fileName); //String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.sepairator + fileName; //Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath)); //request.setDestinationUri(localStorageBasePathUri); DownloadManager downloadManager = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE); Long downloadId = downloadManager.enqueue(request); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.