The problem is I have no clue as to how android wants me to call that sound as a string rather than a int...
Array of 7 sounds -> dropped into random generation -> String is created -> play "string"...here's where I'm stuck
My java so far...
package com.cyphasignals.jelloman;
import com.cyphasignals.jelloman.SoundManager;
import java.util.Random;
import android.app.Activity;
import android.content.res.Resources;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class JelloMan extends Activity {
private SoundManager mSoundManager;
/** Called when the activity is first created. */
private String[] myString;
private static final Random rgenerator = new Random();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, q);
ShakeListener MyShake = new ShakeListener((SensorManager) getSystemService(SENSOR_SERVICE));
MyShake.setForceThreshHold(1.9);
MyShake.setOnShakeListener(new ShakeListener.OnShakeListener() {
@Override
public void onShake() {
mSoundManager.playSound(q);
}
});
ImageButton mouthbutton = (ImageButton)findViewById(R.id.billmouth);
mouthbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(q);
}
});
}
}
Outsourced "SoundManager.java"
package com.cyphasignals.jelloman;
import java.util.HashMap;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class SoundManager {
private SoundPool mSoundPool;
private HashMap<Integer, Integer> mSoundPoolMap;
private AudioManager mAudioManager;
private Context mContext;
public SoundManager()
{
}
public void initSounds(Context theContext) {
mContext = theContext;
mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
mSoundPoolMap = new HashMap<Integer, Integer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
public void addSound(int Index,int SoundID)
{
mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));
}
public void playSound(String q) {
int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(q), streamVolume, streamVolume, 1, 0, 1f);
}
public void stopSound(int Index, int SoundID) {
mSoundPool.stop(mSoundPoolMap.get(1));
}
}
*If anyone knows a simpler way, it would be truly appreciated


