startActivity를 실행할때 Calling from outise of and Activity가 뜰 때가 있다.
정확한 코드는 이렇게 Calling --- from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
이럴 때는 Intent를 줄때 addFlags(Intent.FLAG_ACITIVITY_NEW_TASK)를 옵션으로 주면 잘 돌아간다.
예시는 아래와 같다
Intent intent = new Intent(context, cls);
context.startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
프로젝트에 있는 코드를 긁어온거라 완전하게 어디에든 적용가능한 Pure한 형태는 아니지만..
충분히 간단한 코드이므로 필요한 곳에 적용이 가능하리라 봄(Spring 아님ㅎ;)..
참조할만한 개념이 있어 첨부한다
Task (4.1) - 새로운 task 생성 [FLAG_ACTIVITY_NEW_TASK] (tistory.com)
'Android > Technic' 카테고리의 다른 글
DialogFragment 높이, 너비 조절 (0) | 2021.06.10 |
---|---|
DialogFragment 뒷 배경 지우기 (0) | 2021.06.10 |
Android webview lazy loading 시 느릴때 고려점 (0) | 2021.06.01 |
Android webview debugger 사용하기 (2) | 2021.05.21 |
안드로이드에서 Video 로딩 시 이상한 그림(Poster) 안 뜨게 하는 방법 (0) | 2021.05.21 |
댓글