Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Slow File Download vs iOS & BlackBerry - DefaultHttpClient
    primarykey
    data
    text
    <p>I am using the following code to download files, and I am finding that the performance is really really slow compared with virtually the same code on iOS and BlackBerry.</p> <p>As well as testing on various different SDK versions and OSX vs Windows, I have also tried the App on various devices - HTC Desire, Samsung Galaxy, Huwei Pulse, HTC Wildfire - all with terrible performance vs. iPhone and BlackBerry devices.</p> <p>Check out this video I made to compare the speeds on the 3 emulators: <a href="http://mepubli.sh/iOSvsAndroidVsBB.mp4" rel="nofollow">Android vs. iOS and BlackBerry</a></p> <p>Here is the Android code:</p> <pre><code>FileOutputStream fos = null; InputStream input = null; try { fos = new FileOutputStream("XXXX"); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("XXXX"); HttpResponse response = httpclient.execute(httpget); input = response.getEntity().getContent(); byte[] buffer = new byte[8192]; int readBytes; while (((readBytes = input.read(buffer, 0, buffer.length)) != -1) &amp;&amp; !thePackage.getPackageStatus().equals( PackageStatus.STATUS_CANCEL_DOWNLOAD)) { fos.write(buffer, 0, readBytes); } } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { } } if (input != null) { try { input.close(); } catch (IOException e) { } } } </code></pre> <p>I've tried BufferedHttpEntity and other buffering/threading strategies, but this version of the code is the best performing out of any of the different options we've tried. I've run extensive code profiling, and can't see too much time being lost between the top level functions and the native code in Dalvik/Apache Harmony.</p> <p>Any ideas would be fantastic, because the bad performance is making our application virtually unusable.</p> <p>Thanks,</p> <p>Nick</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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