0
我的應用程序過去需要幾秒鐘才能加載。現在我添加了聲音,需要15秒才能加載。我加載了40個ogg文件,每個文件大小約爲15KB。這是加載代碼:Android - 加載聲音文件需要很長時間
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);
}
}
}
有什麼辦法來優化呢?