在锁定屏幕上运行的ApplicationIdleDetectionMode,应用程序退出和电池寿命 [英] ApplicationIdleDetectionMode, application exit and battery life of app running on locked screen

查看:106
本文介绍了在锁定屏幕上运行的ApplicationIdleDetectionMode,应用程序退出和电池寿命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在制作一个播放音乐的应用程序,并且我想在手机锁定时也启用播放功能.因此,我必须将ApplicationIdleDetectionMode设置为Disabled.我已阅读并且还注意到该值只能设置一次.我读过的第二件事是 无法以编程方式退出应用程序.我在测试中注意到的第三件事是,如果我的应用程序在锁定屏幕上运行,并且我停止了所有计时器并从中介元素中卸载音频,则与普通锁定相比,它仍然消耗大量电池 模式.与正常锁定模式相比,在锁定屏幕上运行的应用程序甚至可以获得相同的电池寿命吗?如果我的应用程序不使用任何加速度计及其他功能,在屏幕锁定时我还应该停止这些操作吗?他们在路过吗 默认?

我对应用程序的梦想是:
当音频正在播放并且用户已接受后台播放时,该应用程序将在锁定屏幕上运行.
当音频不播放时,应用程序将始终执行常规的逻辑删除,这是在ApplicationIdleDetectionMode为Enabled的情况下完成的. 当手机处于锁定状态时,如果音频播放停止,则该应用程序将执行正常的逻辑删除

前两件事可以完成,但据我所知,第三件事是不可能的.我想有人说我错了:)

-Juuso

Hi,

I am making an application which plays music and I want to enable playback also when phone is locked. So I have to set ApplicationIdleDetectionMode to Disabled. I have read and also noticed that the value can be set only once. Second thing I have read is that application cannot be exited programatically. Third thing which I have noticed in my tests is that if my application is running on locked screen and I stop all timers and unload audio from mediaelement it still uses a lot of battery compared to normal lock mode. Is it even possible to get the same battery life for an application running on locked screen compared to normal lock mode? If my application doesn't use any accelometer&other things should I still stop those when screen is locked? Are they running by default?

The dream that I had for my app was:
When audio is playing and user has accepted background playback, the application will run on locked screen
When audio is not playing the application would always do the normal tombstoning which is done when ApplicationIdleDetectionMode is Enabled
When audio playback stops while phone is locked, the application would do the normal tombstoning

The first two things can be done but as far as I have understood the third thing is impossible. I would like someone to say that I'm wrong :)

-Juuso

推荐答案

Juuso,

我还不了解电池问题,但是我可以为您提供解决该问题的解决方案.

但在此之前,我不得不说:此解决方案可能不是很优雅,如果这是好的还是不好的,您可以就此进行讨论.
另外,如果您执行以下操作,则您的应用程序将完全退出.因此,您无法通过按后退"按钮返回到应用程序.

音频播放完毕后,将数据保存在隔离存储中,然后引发异常.

Hi Juuso,

i don't know yet about the battery problem but I can give you a solution for tombstoning the app.

But I have to say before that: This solution is probably not very elegant and you could discuss about this if this is good or not.
Also if you do the following you app will be exited completely. So you cannot go back to the app by pressing the "back"-button.

When you finish you audio, then you save your data in the isolated storage and then you just throw an exception.

throw new Exception("ExitAppException");


而已.现在,您需要确定您的应用是否可以再次开始唤醒是否必要,或者它不是nexessary.

但是以下内容违反了应用程序认证的要求.


Nothing more. Now you need to decide if it is nessecary that your app can start to wake up again or if it is not nexessary.

But the following is against the requirments for certifications of apps.

5.1.2终止应用程序

应用程序必须处理.NET Framework引发的异常,并且不会意外终止.在认证过程中,将监视应用程序是否意外终止.意外终止的应用程序无法通过认证. 处理异常时,应用程序必须提供用户友好的错误消息.您可能会显示一条与应用程序上下文相关的消息. 在处理异常之后,应用程序必须继续运行并保持对用户输入的响应.显示一般或无用的错误消息的应用程序将无法通过认证.

The application must handle exceptions raised by the .NET Framework and not terminate unexpectedly. During the certification process, the application is monitored for unexpected termination. An application that terminates unexpectedly fails certification. When handling exceptions, an application must provide a user-friendly error message. You may present a message that is relevant to the context of the application. The application must continue to run and remain responsive to user input after the exception is handled. An application that displays generic or unhelpful error messages will fail certification.

因此,通常情况是WP7应该始终让用户对电话进行控制.这是认证过程中所有地方的标准要求(没有阻止的UI等).因此,我认为以任何方式退出应用都将获得控制权 来自用户.

希望能有所帮助.


So the thing generally is that WP7 should give the user always control over the phone. This is a standard requirement everywhere in the certification process (no blocked UI and so on). So I think exiting an app in any way will take the control from the user.

hope that helps a bit.



这篇关于在锁定屏幕上运行的ApplicationIdleDetectionMode,应用程序退出和电池寿命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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