私は別の例に取り組んでいます (ここで見つかりましたMP3 を Android のサウンド プールにロードする)。しかし、何らかの理由で2つのonCreate()
メソッドになってしまい、1つを削除するとエラーが発生します。
MP3 をサウンドプールに一度ロードしてから、他のアクティビティでそれらを呼び出そうとしています。
私のコード:
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);
}
}