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,791
  • 4
  • 26
  • 49
Big Coach
  • 2,485
  • 2
  • 12
  • 31

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,849
  • 3
  • 23
  • 46
1

try method new AsyncTask().executeOnExecutor()

or Use Volley or OkHttp library

mudit_sen
  • 1,470
  • 15
  • 24