Noah
Noah

Reputation: 3

Android play audio after page loaded

After go to go to next activity, I got this code for my next activity

final MediaPlayer mp = MediaPlayer.create(this, R.raw.audio);
mp.start();

The audio play before the page loaded, is there possible to let the audio play after the page loaded?

Upvotes: 0

Views: 31

Answers (1)

AminA2
AminA2

Reputation: 197

when an activity is created, the onCreate method is called, then onStart and then onResume. you can use this methods. but if you are working with network or other time consuming operations to populate your views, you should place your code in the listener which is called when the operation is finished. anyway you should give me more detail!

Upvotes: 1

Related Questions