我的应用程序过去需要几秒钟才能加载。现在我添加了声音,加载需要 15 秒。我正在加载 40 个 ogg 文件,每个文件大小约为 15KB。这是加载代码:
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);
}
}
}
有没有办法优化这个?