I slapped together a simple test application that has a button, and makes a noise when the user clicks on it. Here are it's method:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.easy);
b.setOnClickListener(this);
}
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(this, R.raw.easy);
mp.start();
while(true) {
if (!mp.isPlaying()) {
mp.release();
break;
}
}
}
My question is, why is onCreate acting like it's in a while loop? I can click on the button whenever, and it makes the sound. I might think it was just a property of listeners, but the Button object wasn't a member variable. I thought that Android would just go through onCreate onse, and proceed onto the next lifecycle method.
Also, I know that my current way of seeing if the sound is playing is crap...I'll get to that later. :)
Thank you.