Android 7+:使用Cordova应用进行多窗口检测 [英] Android 7+: Multi-window detection with Cordova apps

查看:212
本文介绍了Android 7+:使用Cordova应用进行多窗口检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们如何在Cordova中处理android的多窗口支持或使用浏览器事件?具体来说,我将pause事件捕获在我的应用程序中并进行清理,因为当该应用程序不在多窗口模式下运行时,实际上意味着该应用程序将进入后台.我使用此回调清除了一些昂贵的内存资源(其中包括正在显示的实时视频供稿).

how are folks handling android’s multi-window support in cordova or using browser events? Specifically, I am trapping the pause event in my app and doing cleanup because when the app is not running in multi-window mode, it actually means the app is going to the background. I use this callback to clear up some expensive memory resources (which includes live video feeds being displayed).

但是,在多窗口模式下,当您将两个应用程序并排放置并在另一个应用程序上执行任何活动时,浏览器会生成pause事件.显然,在这种情况下,我不想进行清理,因为用户界面仍然可见.

However, in multi-window mode, when you lay two apps next to each other and perform any activity on the other app, the browser generates the pause event. Obviously, in this case, I don’t want to do the cleanup because the UI is still visible.

问题是,科尔多瓦是否提供一种方法:

So the question is, does cordova offer a way to:

  • 检测应用是否在多窗口模式下运行
  • 或者,区分pause事件和stop事件(如
  • Either detect if the app is running in multi-window mode
  • Or, differentiate between a pause event and a stop event (as described in this SO thread)

我注意到了注意在cordova讨论中,但作者没有提到哪一行更改.我只发现与androidresizable相关的更改设置为true,但这不是我的问题.该应用程序确实将其窗口显示在多窗口中,并且不会全屏显示.是引起问题的事件.

I noticed a note in cordova-discuss but the author doesn’t mention which one line change. I only found a change related to androidresizable being set to true but that is not my problem. The app does take its window in multi-window and doesn’t go full screen. Its the events that are causing issues.

推荐答案

我拼凑了一个cordova插件,如果该应用程序在多窗口中,则返回true;否则,返回false.还可以让您捕获onStoponStart,这在多窗口模式下尤其重要.

I cobbled together a cordova plugin that returns true if the app is in multi-window and false if not. Also allows you to trap onStop and onStart which are important in multi-window mode, specifically.

这是我的第一个插件,如果不好,可以随时进行PR和改进.

This is my first plugin and if its bad, feel free to PR and improve.

链接: https://github.com/pliablepixels/cordova-plugin-multi -窗口

这篇关于Android 7+:使用Cordova应用进行多窗口检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆