I created a photoalbum. I\'ve got 70 activities and in everyone is one Image (jpeg, png). And two arrows to go Back and forth. The Images are saved in drawable-folder. I kno
Add this in your AndroidMainfest.xml file:
android:hardwareAccelerated="false"
android:largeHeap="true"
inside applicaton tag like this:
<application
android:hardwareAccelerated="false"
android:largeHeap="true"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The problem is that you don't finish previous activities, that's why recycle bitmap doesn't help. If you want to continue implement gallery in this way you can set image in onStart and remove it in onStop or override back button, finish and track your activities and relaunch them when back pressed.
First of all you should scale your images down,this decreases the amount of memory used.Here's a good tutorial on that: Loading large bitmaps efficiently
Then you should only have the one picture that is displayed inside your memory. So before starting the new activity recycle your Bitmap and set it to null, the gc will take care of it.