• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Making a sound repeat

cr5315

Android Enthusiast
Jul 23, 2010
434
158
Narnia
cr5315.com
I have an app that plays a sound when it is opened, but I would like it to repeat until the app is closed. I've gotten the sound to play once, but I can't figure out how to make it repeat.

Code:
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;

public class ObeyActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.laugh);
        mp.start();
    }
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones