I have an application for streaming music and I want to display a foreground notification when music is playing. I am streaming in a separate service, and the code that I use to notify the foreground is as follows:
Notification notification = new Notification(R.drawable.ic_stat_notification, getString(R.string.app_name), System.currentTimeMillis()); Intent notificationIntent = new Intent(this, PlayerActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(this,getString(R.string.app_name), getString(R.string.streaming), pendingIntent); startForeground(4711, notification);
The symbol is displayed on the taskbar, and if I click on the notification, the application opens, but this is a complete new activity (I think due to the creation of a new intention). Therefore, if I have, for example, a dialog box open in the application is not open, if I reject the application (by clicking on it) and then click / click on the application icon in the notification panel. How can I handle this to show "old / real" activity?
source share