我正在使用该方法显示Notification
背景。Service
startForefround()
if (notif == null) {
// Create the pending intent
Intent intentForeground = new Intent(this, BackgroundLocationService.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intentForeground, 0);
notif = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setDefaults(Notification.DEFAULT_ALL)
.setTicker(getText(R.string.location_service_starting))
.setOnlyAlertOnce(true)
.setOngoing(true)
.setContentIntent(pendIntent)
.build();
notif.flags |= Notification.FLAG_NO_CLEAR;
}
startForeground(notificationID, notif);
它正确地向用户显示通知,当我向下滑动通知栏时,我想让用户点击通知并返回我的应用程序。我怎样才能做到这一点?