Audio playback after navigating by activity is complete

I am writing Activity. It is supposed to display some representation and play sound. Everything is fine except ... I'm not sure where to put the code in the sound.
I am currently playing it in the onCreate()

Activity method , but the sound starts playing before the Activity has finished transitioning. I would really like the sound to play after the transition is complete and the entire view is visible.
Is there any method I can override / any listener I can implement that gets called after the transition is complete? Is there a way to find out the duration of the transition so I can just postDelayed(Runnable action, long delayMillis)

in the view?

+3


source to share


1 answer


Have you tried putting your code to play audio in onResume()

? Because it is called when "Activity" is in the foreground.

From Docs



onResume () -

Called after onRestoreInstanceState (Bundle), onRestart (), or onPause () to make your activity start interacting with the user. This is a good place to start animations, open exclusive devices (like a camera), etc.

0


source







All Articles