Reputation: 6160
I have MyActivity and MyService (which plays music). I have also notification (in Notifications bar) but when I press it, MyActivity opens up in default state (play button is not pressed for e.g., although the music is still playing). This worked OK before I started to work with binding - I am concerned it has to do something with it.
What could be wrong?
EDIT:
This is my Noification inside my service:
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
new Intent(getApplicationContext(), SoundRelaxerActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new Notification();
notification.tickerText = "Soundrelaxer: "+trackTitle;
notification.icon = R.drawable.play;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.setLatestEventInfo(getApplicationContext(), "SoundRelaxer","Playing: " + trackTitle, pi);
startForeground(1, notification);
Upvotes: 0
Views: 177
Reputation: 8176
Try adding this flag to the Intent
you're using in your Notification:
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
That way a new instance of your Activity will not be created if it exists.
Upvotes: 1