My app used to take a few seconds to load. Now that I added sound it takes 15 seconds to load. I am loading 40 ogg files, each about 15KB in size. This is the loading code:
public static void Load(Context context, Resources resources) {
soundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
sounds = new int[5][8];
audioManager = (AudioManager) context
.getSystemService(Context.AUDIO_SERVICE);
actualVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 8; j++) {
sounds[i][j] = soundPool.load(context, resources.getIdentifier(
"kalimba_c" + Integer.toString(i + 3) + "_"
+ Integer.toString(j + 1), "raw",
ColorLock.PACKAGE_NAME), 1);
}
}
}
Is there any way to optimize this?
The problem is not with the code that loads the sound files into the SoundPool. I disabled this code and the app still took 15 seconds to load. After deleting the files from the project load time decreased back to a few seconds.