1

I have a list with id's which i'm going to use in URL's, to get some data using HttpConnection. I was trying to use AsyncTask from the loop, but it was a bad idea, because my program crashed with:

java.lang.OutOfMemoryError: Failed to allocate a 124606360 byte allocation with 16777216 free bytes and 103MB until OOM

How to make many connections one after another correctly?

Pushpendra
  • 2,723
  • 4
  • 24
  • 47
Big Coach
  • 2,175
  • 2
  • 11
  • 29

2 Answers2

2

You can try to add android:largeHeap="true" your in your AndroidManifest.xml

<application
    android:allowBackup="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

Or you can try using network library such us Volley, Okhttp, Retrofit, etc.

zihadrizkyef
  • 1,652
  • 2
  • 17
  • 39
1

try method new AsyncTask().executeOnExecutor()

or Use Volley or OkHttp library

mudit_sen
  • 1,368
  • 14
  • 24