簡體   English   中英

Nativescript Angular:Android 全屏關閉手機鎖

[英]Nativescript Angular:Android fullscreen turned off on phone lock

我正在使用下面的代碼使我的應用程序全屏顯示,但是當有人鎖定他的手機而不是解鎖它時,全屏關閉:

  ngOnInit(): void {
    this.goFullscreen();
  }
   private goFullscreen() {
    if (androidApp && device.sdkVersion >= '21') {
      const View = android.view.View;
      const window = androidApp.startActivity.getWindow();
      const decorView = window.getDecorView();
      decorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
          View.SYSTEM_UI_FLAG_FULLSCREEN |
          View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
      );
    }
  }

有什么方法可以讓應用在手機解鎖時再次全屏顯示?

收聽恢復事件並設置全屏。 您還可以在頁面組件的基本組件 class 中使用它。

import { on as applicationOn, resumeEvent, ApplicationEventData } from "tns-core-modules/application";

export class BaseComponent {

    constructor() {
        
        applicationOn(resumeEvent, (args: ApplicationEventData) => {
            //set full screen here
        });
     }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM