1
startForefround()
메서드를 사용하여 의 배경에 Notification
을 표시하고 있습니다.Android 사용자가 내 알림을 누르고 내 앱으로 돌아 가기
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);
그것은 정확하게 사용자에게 알림을 표시하고 내가 알림 표시 줄을 아래로 슬라이드 때 사용자가 알림을 누르고 내 응용 프로그램에 반환하고 싶습니다. 어떻게해야합니까?
아, 나는 MainActivity.class 부분을 누락되었습니다. 감사! –