Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:18:13+00:00 2026-06-04T00:18:13+00:00

I get an error when I load a background image before I load another

  • 0

I get an error when I load a background image before I load another image on top of it. The logcat points to memory error but the background is only 17kb in size.

Here the code in sequence of events

package com.firm.armouredassault;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.os.Bundle;

public class StartNewGame extends Activity {

    MyGame ourView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);    
    //setContentView(R.drawable.canvas);

        ourView = new MyGame(this);
        setContentView(ourView);

    }




}

MyGame.java:

package com.firm.armouredassault;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;

public class MyGame extends View {

    Bitmap BTank, TShell;

    public MyGame(Context context) {
        super(context);
        // TODO Auto-generated constructor stub

    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);


        canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),
                R.drawable.bluetanksm), 10, 200, null);

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:18:15+00:00Added an answer on June 4, 2026 at 12:18 am

    If the option don’t vary when you call BitmapFactory.decodeResource, can’t you put the result in a field and reuse this value for every call to onDraw.

    I don’t think this is an answer or will solve your problem, but I guess your app will feel a lot better no to have to decompress a jpeg everytime you want to display it on screen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when trying to load a Zend Framework application: Fatal error:
When running rspec I get the following error: no such file to load --
Why I get error with this query on my live server but not on
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I am using following PHP code for trigger creation but always get error, please
I am trying to load an image in the background and then update the
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
I have this query and I get error Operand should contain 1 column(s), whats
What is the best way to get error messages from a WF4 workflow back
When we try to create a view within a funcion we get ERROR: there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.