You're referencing an invalid Activity, in this case the soundEffect
class. Just extending the Activity class won't give you all the pleasures of an Activity unless that Activity is explicitly called with onCreate(...) to set-up resources, etc.
You can remove the "extends Activity" from you soundEffects
class, and instead, replace your
public void InitializeAudio()
{
Log.d("TEST", "initAudio method called");
sp = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
Log.d("TEST", "sound pool created sp= " + sp);
shot = sp.load(this, R.raw.gunshot, 1);
Log.d("TEST", "Audio is loaded :)");
}
with
public void InitializeAudio(Context context)
{
Log.d("TEST", "initAudio method called");
sp = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
Log.d("TEST", "sound pool created sp= " + sp);
shot = sp.load(context, R.raw.gunshot, 1);
Log.d("TEST", "Audio is loaded :)");
}
And pass a reference from you main Activity, which would appear to be your Display
class, up through gun.reload(..)
, which should be gun.reload(Context context)
.