Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloads the same file twice?
    text
    copied!<p>Hi i've been looking through various parts of my code to try and find out whats happening but can't seem to figure it out. The following code is supposed to be downloading two files one called "clientraw" and one called "clientrawextra" but for some reason when i look in the directory there are 2 versions of each file "clientraw...1..." "clientrawextra...1..." </p> <p>Therefore it seems like it's downloading the files multiple times and i have no idea why?? </p> <p>Thanks in advance!</p> <pre><code> distance dis = new distance(); dis.findURL(value); String url = dis.findURL(value); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); // in order for this if to run, you must use the android 3.2 to compile your app if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "clientraw.txt"); // get download service and enqueue file DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); ///////////////////////////////////////////////////// distance disextra = new distance(); disextra.findextra(value); String urlextra = disextra.findextra(value); DownloadManager.Request requestextra = new DownloadManager.Request(Uri.parse(urlextra)); // in order for this if to run, you must use the android 3.2 to compile your app if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) { requestextra.allowScanningByMediaScanner(); } requestextra.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "clientrawextra.txt"); manager.enqueue(requestextra); mDownload = new DownLoadComplte(); registerReceiver(mDownload, new IntentFilter( DownloadManager.ACTION_DOWNLOAD_COMPLETE)); </code></pre> <p>And the broadcast receiver...</p> <pre><code>private class DownLoadComplte extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equalsIgnoreCase( DownloadManager.ACTION_DOWNLOAD_COMPLETE)) { Intent myIntent = new Intent(splash.this, MainActivity.class); myIntent.putExtra("key", value); //Optional parameters myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //unregisterReceiver(mDownload); splash.this.startActivity(myIntent); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload