내 앱이 백그라운드에서 실행 중일 때 알림이 알림 바에 표시되는 방법을 구현했습니다. 알림을 클릭하면 앱을 닫습니다.android 알림을 클릭 한 후 애플리케이션 종료
Intent intent = new Intent(this, Main.class);
PendingIntent pIntent = PendingIntent.getActivity(this,
(int) System.currentTimeMillis(), intent, 0);
if (Build.VERSION.SDK_INT < 16) {
Notification n = new Notification.Builder(this)
.setContentTitle("Flashlight")
.setContentText("turn off")
.setSmallIcon(R.mipmap.light_on)
.setContentIntent(pIntent)
.setAutoCancel(true).getNotification();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
} else {
Notification n = new Notification.Builder(this)
.setContentTitle("Flashlight")
.setContentText("turn off")
.setSmallIcon(R.mipmap.light_on)
.setContentIntent(pIntent)
.setAutoCancel(true).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
}
어떻게하면됩니까?
"close app"이란 정확히 무엇을 의미합니까? –
@MikeM. 스택에 다른 활동이 없습니다. 백그라운드에서 실행중인 유일한 활동입니다. 클릭 후 내 성화를 끄고 – DastakWall