개요
일부 Android 기기에서는 권한 요청, 대화상자, 화면 키보드 같은 시스템 창이 앱 위에서 닫힌 뒤 앱 화면이 검게 남을 수 있습니다. 앱은 계속 실행 중이지만 다음 변경이 있을 때까지 아무것도 그려지지 않습니다.
KlugBlackScreen은 그런 창이 닫히는 즉시 앱의 뷰를 다시 그립니다. 시작할 때 한 번 켜 두면 백그라운드에서 자동으로 동작합니다. 특수한 경우에는 직접 실행할 수도 있습니다.
기능
- 자동 모드: 한 번 켜 두면 모든 시스템 창 뒤에 다시 그림
- 특수한 경우를 위한 수동 다시 그리기
- 깜빡임 없는 부드러운 다시 그리기와 까다로운 경우를 위한 더 강한 다시 그리기
- 다른 플랫폼에서는 아무 동작도 하지 않으므로, 코드를 크로스 플랫폼 앱에 그대로 둘 수 있음
지원 플랫폼
Android arm64 · armv7
시작하기
애플리케이션 디스크립터에 확장을 추가합니다:
<extensions>
<extensionID>com.klug.blackscreen</extensionID>
</extensions>
코드 예제
세 가지 흐름입니다. 모든 호출은 즉시 반환되며 Android UI 스레드에서 작업을 수행합니다. 다른 플랫폼에서는 호출이 아무 동작도 하지 않습니다.
1 · 시작 시 한 번 켜기
import com.klug.blackscreen.BlackScreen; // once, in the constructor of your main class: from now on the view is redrawn // whenever the app window gets the focus back, after a permission prompt, // a dialog, the keyboard or another activity BlackScreen.getInstance().startAuto(); // a second call has no effect // iOS, macOS and desktop: isSupported is false and every call does nothing, // so no platform check is needed. stopAuto() switches it off again (rarely needed).
2 · 시스템 창이 닫힌 뒤 다시 그리기
// call this from the result handler of any system window that covered the app: // a permission prompt, a share sheet, a native dialog, a sign-in page function onSystemWindowClosed():void { BlackScreen.getInstance().fix(); // redraw once, no flicker } // example: your own permission flow reports back myPermissionFlow.onResult = function( granted:Boolean ):void { onSystemWindowClosed(); if ( granted ) startCamera(); else showPermissionHint(); };
3 · 앱으로 돌아올 때 더 강하게 다시 그리기
import flash.desktop.NativeApplication; import flash.events.Event; // back from another activity (share sheet, browser, system settings) and fix() // is not enough on a given runtime build: the stronger redraw may flicker once NativeApplication.nativeApplication.addEventListener( Event.ACTIVATE, function( e:Event ):void { BlackScreen.getInstance().fixHard(); }); // the first fixHard() replaces the launch background of the window with plain white, // so the short toggle does not show the splash image
API 개요
| BlackScreen.getInstance() | 단일 인스턴스를 반환합니다. |
| isSupported | Android에서는 true이고, iOS, macOS, 데스크톱에서는 false이며 이 경우 모든 호출이 아무 동작도 하지 않습니다. |
| startAuto() | 시스템 창이 닫힌 뒤처럼 앱 창이 포커스를 되찾을 때마다 자동으로 다시 그립니다. 시작할 때 한 번 호출하세요. 두 번째 호출은 효과가 없습니다. |
| stopAuto() | 자동 모드를 중지합니다. |
| fix() | 깜빡임 없이 뷰를 한 번 다시 그립니다. |
| fixHard() | 까다로운 경우를 위한 더 강한 다시 그리기이며 짧은 깜빡임이 있습니다. 첫 호출은 창의 실행 배경을 단색 흰색으로 교체합니다. |
요구 사항
| AIR SDK | 51.x (HARMAN) |
| Android | Android 6.0 (API 23) 이상 |
| 권한 | 없음 |