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. Pdf shows with video and other content

Hi at all,

I want write an application which shows an PDF with some other content
on it, like Video and image.

Generically I want shows an pdf with some other View on it.
I am concern about PDF, I read some article which explaine how to show
an PDF but I want show an PDF with some other stuff.

Do you recommend me some solution or a right way?

Thanks a lot.

-- 

2. Listen to UEvents

Hi,

I am trying to create a Java service that listens to kernel netlink uevent 
in order for it to detect when a Usb device is plugged-in/out.(is there a 
more simple way to do this in 2.2. ?)

Basically I want a kernel uevent -> broadcast intent service

I found a few classes in the Android source that listen to netlink events. A 
few are daemons like vold and netd and these run as root(and it is not 
possible for a apk installed content to run as root ).

I also found android.os.UEventObserver used by the system_server(I think) to 
do things like dock detection those are found in 
frameworks//base/services/java/com/android/server/ and are called 
DockObserver , HeadsetObserver, BatteryService and HDMIObserver.

UEventObserver spawns a thread that will call native code found in 
hardware/libhardware_legacy/uevent. This code basically opens the socket
and binds to receive broadcast messages.I believe this happens in the 
system_server who runs as user "system" 

When I try to mimic this behavior I get (as expected?)  the following 
exception:
/ActivityManager(   62): Start proc com.sample.android.platform.core for 
broadcast 
com.sample.android.platform.core/com.sample.android.platform.service.PlatformServer:
 
pid=244 uid=1000 gids={3002, 3001, 3003}
D/PlatformServer(  244):  Starting
I/UsbDeviceObserver(  244): new Device Observer
W/dalvikvm(  244): threadid=7: thread exiting with uncaught exception 
(group=0x4001d800)
E/AndroidRuntime(  244): FATAL EXCEPTION: UEventObserver
E/AndroidRuntime(  244): java.lang.RuntimeException: Unable to open socket 
for UEventObserver
E/AndroidRuntime(  244):        at 
android.os.UEventObserver.native_setup(Native Method)
E/AndroidRuntime(  244):        at 
android.os.UEventObserver.access$000(UEventObserver.java:39)
E/AndroidRuntime(  244):        at 
android.os.UEventObserver$UEventThread.run(UEventObserver.java:97)

(you can see I run a system user by the 1000 system userid) and I have the 
following permission declared
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Hence my question(s):
system_server who runs as user "system" how can is bind to a port < 1024 ? 
did I miss something?
How can I get  notifications of events (like usb plugging) into my 
application? I plan to talk to the plugged usb device using libusb.

Greetings

P.S. I also found this thread on a similar subject

3. Droid Pro not working properly with soft keyboards

4. Sorry OOT.. Layanan BB saya mau dihentikan.. Beneran ga inI?

5. "adb devices" command produced device serial number contains no <consolePort> field

6. Inflating views in a ListAdapter

7. Custom preference