当我运行我的应用程序时,它显示“超过最大数量的OpenCore实例”错误。如何解决此错误。 谢谢
答案 0 :(得分:3)
如果您实例化MediaPlayer的多个实例,则会发生以上情况。
您应该阅读the lifecycle of the media player and its different states
Media Player被定义为类范围变量,并在OnCreate()方法
中实例化 private void startPlayingAudio()
{
try {
Uri path1 = Uri.parse("android.resource://com.yourpackagehere./" + R.raw.beep);
mp.reset(); // reset to idle state
mp.setDataSource(this, path1); // from idle to initialised state
mp.prepare();
mp.start();
} catch (Exception ioe) {
Log.e(LOG_TAG, "Error playing the beep sound");
}
}