728x90

win.addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);

WindowManager를 사용하면, Activity의 제약사항을 뛰어넘어서 개발할 수 있다.
- Context별 사용법을 정확히 알아야한다.
- 메모리 관리를 잘 해야 한다.
- 잠금 해제는 Activity Context 만 가능하다.


팝업창 구현이 쉽지 않다. 최상위 팝업 구현을 하려고 하는데 전화가 걸려오면 최상위로 팝업되는 경우도 있고 뒤로 숨는 경우도 있다.

그래서 블로드, 사이트 등에서 기능을 찾아 정리해보고 있지만, 완벽한 해결이 되지 못했다.


https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html


FLAG_DISMISS_KEYGUARD
window가 attach되면 잠금해제를 하는 flag.
Activity Context를 가진 윈도우매니저에서만 동작

FLAG_LAYOUT_NO_LIMITS

allow window to extend outside of the screen.

window가 화면을 벗어나서도 배치될 수 있다.
숨기거나 일부만 보이는 윈도우를 만들때 사용

FLAG_LAYOUT_IN_SCREEN

place the window within the entire screen, ignoring decorations around the border (such as the status bar).

window가 보여지는 화면의 전체 영역을 가진다.
status bar 혹은 navigation bar 영역까지도 배치될 수 있다.

FLAG_NOT_FOCUSABLE

this window won't ever get key input focus, so the user can not send key or other button events to it.

해당 윈도우가 input focus를 받지 않게 된다.
즉 home button 이나 back button처럼 focus를 받아야 동작하는 것들을 다음 우선순위 window에 넘긴다.

FLAG_NOT_TOUCH_MODAL

even when this window is focusable (its FLAG_NOT_FOCUSABLE is not set), allow any pointer events outside of the window to be sent to the windows behind it.

해당 윈도우가 터치를 받지 않게 된다.
터치가 오면 다음 우선순위 window에 넘긴다.


FLAG_KEEP_SCREEN_ON
as long as this window is visible to the user, keep the device's screen turned on and bright.


FLAG_WATCH_OUTSIDE_TOUCH
if you have set FLAG_NOT_TOUCH_MODAL, you can set this flag to receive a single special MotionEvent with the action MotionEvent.ACTION_OUTSIDE for touches that occur outside of your window.


FLAG_SHOW_WHEN_LOCKED
This constant was deprecated in API level 27. Use showWhenLocked or setShowWhenLocked(boolean) instead to prevent an unintentional double life-cycle event.


FLAG_TURN_SCREEN_ON
This constant was deprecated in API level 27. Use turnScreenOn or setTurnScreenOn(boolean) instead to prevent an unintentional double life-cycle event.



//화면 켜놓기 유지(단말이 sleep 단계로 들어가지 않게 설정)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

//화면 켜놓기 안유지
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


// Title Bar 없는 상태로 만들기
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

// Java Code에서 Status Bar와 Title Bar 모두 없는 상태 만들기
requestWindowFeature(Window.FEATURE_NO_TITLE);

// AndroidManifest.xml 에서 Activity의 Theme를 위와 같이 설정해주면 Title Bar가 모두 없는 상태가 된다.
<activity android:name=".MyActivity"
 android:theme="@android:style/Theme.NoTitleBar">

참고 사이트

https://github.com/inez/CustomIncomingCallScreen




블로그 이미지

Link2Me

,