How to Scale an image or resize to avoid out of memory error?
<p>I'm new to development and I've been trying to make a simple game for a while now, and I'm not able to make it work properly because it keeps getting out of memory issues on most devices.</p>

<p>I reduced the image sizes as much as I can and my biggest image is 117kB. </p>

<p>My images are stored in a single drawable folder. I don't think using xxhdpi or xhdpi separately is required for my images. so in the manifest i have mentioned all the support screen sizes code.</p>

<p>I tried the following thing in my manifest but it didn't help.</p>

<pre><code>    android:largeheap = "true"
    android:noHistory = "true" (for every activity so that it doesn't stack up over each other)
</code></pre>

<p>I have about 50 activities ( all with separate formats so can't make just 1 activity) and these activities are generated randomly from a common application class.</p>

<p>My Q1.java</p>

<pre><code>    public class Q1 extends Activity {
    TextView textview;
    int score;
     MediaPlayer player;
   TextView scored;
   LinearLayout imageview3;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_q1);


    scored = (TextView) findViewById(R.id.score);
    imageview3 = (LinearLayout) findViewById(R.id.scoreview);
    Intent mintent = getIntent();
    score = mintent.getIntExtra("score", 0);
    scored.setText(String.valueOf(score));


    TextView scrolltext=(TextView) findViewById(R.id.scrolltext);
    Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/panicStricken.ttf");

    scrolltext.setTypeface(custom_font);

}

public void button(View view) {
    player = MediaPlayer.create(Q1.this, R.raw.correct);

    player.setVolume(50,50);
    player.start();

    Class activityToShow = ActivityList.getInstance().getRandomActivity();

    Intent intent = new Intent(this,activityToShow );
    intent.putExtra("score", score);

    startActivity(intent);


}

public void fedex(View view) {
    player = MediaPlayer.create(Q1.this, R.raw.wrong);

    player.setVolume(50,50);
    player.start();
    score = score - 1;
    scored.setText(String.valueOf(score));
    if (score == 0) {
        Intent intent = new Intent(this, GameOver.class);
        startActivity(intent);
    }
}
@Override
public void onBackPressed() {



    Intent intent = new Intent(this,MainMenu.class);

    startActivity(intent);

    super.onBackPressed();
    finish();
}
</code></pre>

<p>my layout_q1 xml</p>

<pre><code>      &lt;ImageView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/scoreview"
    android:background="@drawable/pic"
    android:onClick="pic"
    android:layout_marginTop="50dp"
    android:id="@+id/imageView11" /&gt;
</code></pre>

<p>I know there's an article about <a href="https://developer.android.com/training/displaying-bitmaps/load-bitmap.html" rel="nofollow">loading large bitmaps efficiently</a> 
but I'm not that great at programming and it's still a little tricky for me to take code and apply it into my own app.</p>

<p>Can someone help me with the best way I can go about this?. </p>

<p>I don't think I can reduce the size of the images further. The best I could do maybe is keep all the image sizes to an average of 50kB, that's about 50 images of 50kB.</p>

<p>When android loads up all these images together will my size reduction be enough to stop this out of memory nightmare?</p>