title: How to access soundPool from a thread other than main/UI?
body: <p>I have my main Activity class, a Renderer class and my custom soundPool class (called soundMan) and I can create and access SoundPool(I.E. soundMan) objects within my Activity class without too many problems.</p>
  
  <p>However, this isn't much good to me, I create all of my objects from resources within my Renderer class (GLSurfaceView.Renderer) which is running on a separate thread.</p>
  
  <p>So, when I attempt to create a new soundPool (soundMan) object from my renderer class, I get the error "can't create handler inside thread that has not called looper.prepare()"</p>
  
  <p>I'm sure there must be a way around this, but I can't work it out.  Any help would be appreciated.</p>
  
  <p><strong>Code and examples follow</strong></p>
  
  <p><em>My Custom soundPool class</em></p>
  
  <pre><code>public class soundMan extends Activity {
  
  //Simple soundPool class
  
  private SoundPool soundPool;
  private int soundID;
  
  soundMan(Context myContext){
      soundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
      soundID = soundPool.load(myContext, R.raw.matches, 1);      
  
  }
  
  public void PlaySound(){
  
      soundPool.play(soundID, 0.9f, 0.9f, 1, 0, 0);
  
  
  }
  
  }
  </code></pre>
  
  <p><em>I can create and use an object within my Activity class like so (in onCreate):</em></p>
  
  <pre><code>soundMan soundPlay = new soundMan(this);  //Create object
  soundPlay.PlaySound();                    //Play the sound
  </code></pre>
  
  <p><em>However, I want to be able to do the same as the above but from my <strong>rendering</strong> thread</em></p>
  
  <p>I know I can set my soundMan object in my Activity class to static and use it like this:</p>
  
  <pre><code>MainActivity.soundPlay.PlaySound();
  </code></pre>
  
  <p>But this is obviously not a good way to achieve what I'm after.</p>
  
  <p>Again, examples (with code) would be appreciated.</p>