DevDroid
DevDroid

Reputation: 93

Reusable Activity

Scenario is like this, I have a Media player which plays the music onClick of song in playlist. It is working fine in my case. But the problem is that, I want a button on each screen which directly take to Media Player. If I use startActivity(intent); on onClick of the button it creates new music player Activity. I dnt want that, I want to reuse my previous media player Activit

Upvotes: 1

Views: 110

Answers (2)

André Oriani
André Oriani

Reputation: 3613

I am imagining that you have the activity on the bottom of the current Activity stack , and you want to bring that activity to the top. You need to set some flags on the intent with Intent.addFlags(). Check the documentation for Intent and the flags FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_REORDER_TO_FRONT. Also consider singleTop and singleInstance activities

Upvotes: 1

Pratik
Pratik

Reputation: 30855

You can use the Background service to take of your now playing song and start the activity and get the current playing progress from service and set in the activity.

Also set the flag for history to launch and start the activity from history also.

Upvotes: 0

Related Questions