我正在研究另一个示例(在此处找到Loading MP3s into the Sound Pool in Android)。但由于某种原因,我最终得到了两种onCreate()
方法,如果我删除一种方法,我就会出错。
我试图将 MP3 加载到 Soundpool 中一次,然后在其他活动中调用它们。
我的代码:
class MyApp extends Application {
private static MyApp singleton;
private static SoundPool mSoundPool;
public onCreate() { // ##### Deleting this gives me errors ###, not deleting it gives me 1 error.
super.onCreate();
singleton = this;
mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);// Just an example
}
public static MyApp getInstance() {
return singleton;
}
public SoundPool getSoundPool() {
return mSoundPool;
}
}
public class TestAndroidGlobalsActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}