keepRunning设置为false - 这是什么,它​​确实在Android? [英] keepRunning set to false - what does it really do on Android?

查看:197
本文介绍了keepRunning设置为false - 这是什么,它​​确实在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,只要它正在运行,并且服务器连续地推压状态更新到客户端,保持活性WebSocket连接到一个服务器的应用程序。

当应用程序发送到后台,我希望它被暂停(不关闭),并根据科尔多瓦文件设置 KeepRunning 为假应该做的伎俩。但我还是看到显示器的应用和我的WebSocket的日志,网络流量后,应用程序被发送到后台,所以它并没有完全停止。

所以我想我只是杀了网络连接的应用程序转到后台权利之前,但有问题的:在暂停 - 活动的应用程序后,大火被带回前台,就在接近恢复 - 活动的火灾。

如何你们处理这个?是否在你的情况下,这个工作呢?


解决方案

似乎<一个href=\"https://github.com/remy/phonegap_test/blob/master/plugins/org.apache.cordova.plugin.websocket.WebSocket/src/android/WebSocket.java\"相对=nofollow> WebSocket.java 不处理的的onPause 插件管理事件,这意味着套接字未关闭,无论 keepRunning 配置设置。

根据这个帖子<一个href=\"http://stackoverflow.com/questions/26225694/phonegap-cordova-pause-event-triggered-on-resume-for-android-can-not-turn-off\">Phonegap /科尔多瓦暂停事件触发简历上为Android;无法关闭音频结果可以将 keepRunning 以的真正的修复与暂停事件的问题,它不会影响当前的的WebSocket 功能。

您可能需要停止JS定时器自己,那么,在你的code,如果你使用的。

您可以找到关于 keepRunning 在我的岗位使用这里

I have an application that keeps an active WebSocket connection to a server as long as it is running and the server continuously pushes state updates to the client.

When the app is sent to the background, I want it to be halted (not shut down) and according to the Cordova Doc setting "KeepRunning" to "false" should do the trick. But I still see network traffic in monitor apps and logs of my websocket after the app was sent to the background, so it wasn't completely halted.

So I thought I simply kill the network connections right before the app goes to the background, but there's the issue: the "pause"-Event fires after the App was brought back to the foreground, right before the "resume"-Event fires.

How are you guys dealing with this? Does this work in your cases?

解决方案

Seems that WebSocket.java doesn't handle onPause event from PluginManager, and it means that sockets are not closed regardless keepRunning config setting.

According to this post Phonegap / Cordova pause event triggered on resume for android; can not turn off audio as a result you can set keepRunning to true to fix the issue with the pause event, and it doesn't affect current WebSocket functionality.

You may need to stop JS timers yourself then, in your code, if you use any.

You can find some relevant info about keepRunning usage in my post here

这篇关于keepRunning设置为false - 这是什么,它​​确实在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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