@Override
protected void onPause() {
Intent notificationIntent = new Intent(getBaseContext(), Music.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(getBaseContext(), 0, notificationIntent, 0);
Notification n = new Notification.Builder(Music.this)
.setContentTitle("Music PLayer")
.setContentText("Subject")
.setContentIntent(intent)
.setSmallIcon(R.drawable.icon)
.setAutoCancel(true).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
super.onPause();
}
这是一个媒体播放器,每次点击主页按钮都会转到onPause()
音乐仍在播放,seekbar
仍在播放,每次我的活动都在onPause()
时,它会打开通知,当我点击通知时,它会再次返回我的活动。< / p>
问题在于每次我点击它时,它都会启动一个新活动并重置所有内容。我想要的是恢复最后一个仍在运行的活动。