← すべての拡張機能

ネイティブ拡張機能

KlugBlackScreen

com.klug.blackscreen

APMは不要。ダウンロードしてすぐに使えます。これ以上シンプルにはできません。

権限プロンプト、ダイアログ、キーボードなどのシステムウィンドウが閉じた後に、Android で画面表示を復元します。

Android 開発中

概要

一部の Android デバイスでは、権限プロンプト、ダイアログ、画面上のキーボードなどのシステムウィンドウがアプリの上で閉じた後も、アプリの画面が黒いままになることがあります。アプリは動作し続けていますが、次の変化があるまで何も描画されません。

KlugBlackScreen は、そのようなウィンドウが閉じるとすぐにアプリのビューを再描画します。起動時に一度オンにすれば、バックグラウンドで自動的に動作します。特殊なケースでは、直接トリガーすることもできます。

機能

  • 自動モード:一度オンにすれば、システムウィンドウのたびに再描画
  • 特殊なケース向けの手動再描画
  • ちらつきのない穏やかな再描画と、頑固なケース向けのより強力な再描画
  • 他のプラットフォームでは何もしないため、コードをクロスプラットフォームのアプリにそのまま残せます

対応プラットフォーム

Android arm64 · armv7

はじめに

アプリケーション記述子に拡張機能を追加します:

app.xml
<extensions>
    <extensionID>com.klug.blackscreen</extensionID>
</extensions>

コード例

3つのフローです。すべての呼び出しは即座に返り、処理は Android の UI スレッドで行われます。他のプラットフォームでは、呼び出しは何もしません。

1 · 起動時に一度オンにする
Main.as
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 · システムウィンドウが閉じた後に再描画する
Permissions.as
// 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 · アプリに戻るときにより強力に再描画する
Resume.as
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()唯一のインスタンスを返します。
isSupportedAndroid では true。iOS、macOS、デスクトップでは false で、すべての呼び出しは何もしません。
startAuto()アプリのウィンドウがフォーカスを取り戻すたびに、たとえばシステムウィンドウが閉じた後に、自動的に再描画します。起動時に一度だけ呼び出してください。2回目の呼び出しは無効です。
stopAuto()自動モードを停止します。
fix()ちらつきなしで、ビューを一度再描画します。
fixHard()頑固なケース向けのより強力な再描画で、短いちらつきを伴います。最初の呼び出しで、ウィンドウの起動時の背景が無地の白に置き換えられます。

動作要件

AIR SDK51.x(HARMAN)
AndroidAndroid 6.0(API 23)以降
権限なし