Loading the same Bitmap multiple times on Android

by Unai Orbe » Thu, 29 Oct 2009 14:42:10 GMT


Sponsored Links
 Hi, I'm pretty new with Android and I have a doubt about how the resource
loading works.

I'm trying to make a game drawing directly on canvas, and I'm loading the
bitmaps using "BitmapFactory.decodeResource(mResources,
R.drawable.my_image)", my doubt is about the way Android stores/loads these.
I'm going to have to load the same image a few times, so I think I need a
"ResourceManager" for my game, but the R class is confusing me.

When I call the "decodeResource", Android has to actually load the image in
memory or it just gives me a "pointer" to the first image it loaded (when
loading the same image twice or more)? I know I could try checking the
memory it takes when loading the same image lots of times, but I'm just
feeling lazy for that :-P

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. can one cmulator control controls two emulators in the same computor at the same time ?

Hello,
   I'm dealing with a application which associate with GPS mock locations
and XMPP comunication,and need to send the mock location to two emulator by
ADT at the same time .However I've got a problem .It seems that the location
cann't be send to two emulator  in my computor at the same time . So ,may
any master-hand can tell me if it is possible for us to send mock location
to two emulator in the same computor at the same  time ?
   thanks very much.

--~--~---------~--~----~------------~-------~--~----~

2. How can I grab all keys? (including ENTER key)

Hi,
I need to grab all keys in my application, but have a little problem
when I'm using soft keyboard I didn't get event when press ENTER key,
other keys generate event onDown/Up, but onKey event never occurs.

Here is full source code:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;

public class keylogger extends Activity {

   View v;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        v = (View)findViewById(R.id.View01);
        v.setOnKeyListener( new OnKeyListener() {
         public boolean onKey(View v, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            Log.d("test", "onKey");
            return false;
         }
      });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
       // TODO Auto-generated method stub
       Log.d("test", "onKeyDown");
       return super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
       // TODO Auto-generated method stub
       Log.d("test", "onKeyUp");
       return super.onKeyUp(keyCode, event);
    }
}


--------------main.xml--------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<View android:id="@+id/View01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</View>
</LinearLayout>


Cheers,
Marcin.

--~--~---------~--~----~------------~-------~--~----~

3. How do you prevent media from restarting when you rotate an android phone

4. Large Resources

5. Install app on a device?

6. Why does using People._COUNT cause IllegalArgumentException to be thrown?

7. Hi friends