How do you get an activity to behave differently (invoke different methods), depending on where it was launched from?
I have an activity which is launched either when a user chooses a song, or when a user presses a ‘now playing’ button.
Ideally, if a song is selected from activity a, then activity b binds to the service, and tells the service to play the selected song.
If the ‘now playing’ button is selected from activity a, then activity b binds to the service, but doesn’t tell it to start playing the song.
I’ve gathered that this is achievable somehow via either intents, broadcasts, or just a bunch of if statements, but I’m not sure how best to implement this. Thanks for your help.
You can add a flag (or any other extra details) to indicate whether you want the song started or not in the intent send to activity B.
So in Activity A:
Then in onCreate() of Activity B, retrieve the details with: