본문 바로가기
개발/Android

[Android] Notification 진입시 App 중복 실행 해결

by blacktree 2022. 7. 4.
반응형

우리가 Push를 받아 Notification에 보여주고 선택 시 앱을 진입시키는 게 일반적인 방법이다. 

이때 앱이 중복되어서 실행되는 경우가 있다. 

 

개발 중에 앱이 중복 실행되어서 방법을 찾아봤다. 

일단 2가지의 방법이 있다. 

 

1. Intent 설정

val intent = Intent(this, LoginActivity::class.java)
intent.action = Intent.ACTION_MAIN
intent.addCategory(Intent.CATEGORY_LAUNCHER)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
val pendingIntent : PendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)

2. AndroidManifest.xml 에 launchMode를 singleInstance으로 설정한다. 

android:launchMode="singleInstance"

 

참고로, 저 같은 경우는 2번째 방법으로 해결했습니다.

 

728x90
반응형

댓글