Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In an Android App, when are resources loaded to memory?

I've added about 35 images to my res/drawable folder and another 30 sound files to res/raw folder. Now my application takes a good 5 seconds longer to start even tough only 1 image and 1 sound resource is used for the startup screen. That makes me ask: When are my image resources loaded into memory?

Are they loaded when the application starts or when I use them for the first time? (Ex: when I call ImageView.setImageResource(myResId);)

If they are all loaded when the app starts, how can I avoid this? If each one is loaded on demand, why is my application taking longer to start?

Info about app for insight: Single activity with a ViewPager. Each view page uses one of the image resources which is a jpeg file with 700x400 px resolution (~50K) and one of the sound files which is an mp3 file <5 sec (~60K).

like image 291
e-mre Avatar asked Dec 24 '12 20:12

e-mre


People also ask

What is memory status in Android?

1. Check memory through settings. Most android phones let the user monitor the state of memory consumption using memory options in the settings. This option might be named memory or RAM. All you need to do is tap the option to view a breakdown of which processes and applications are occupying the memory.

What is resources in Android application?

Resources are the additional files and static content that your code uses, such as bitmaps, layout definitions, user interface strings, animation instructions, and more. You should always externalize app resources such as images and strings from your code, so that you can maintain them independently.


1 Answers

Are they bitmaps? I found this in the android dev website:

http://developer.android.com/training/displaying-bitmaps/process-bitmap.html

like image 114
recheej Avatar answered Oct 09 '22 01:10

recheej