WP8.1 application crashes on calling RequestProductPurchaseAsync(WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃)
问题描述
我正在为 Windows Phone 8.1 (Runtime) 编写 Audio Player,我为 audio
使用 IBackgroundTask
.
I'm writing Audio Player for Windows Phone 8.1 (Runtime) and I use IBackgroundTask
for audio
.
我想使用应用内购买,但调用时应用程序崩溃
I want to use in-app purchase, but applications crashes on calling
var result = await CurrentAppSimulator.RequestProductPurchaseAsync(ProProductId);
没有任何例外.
这个方法在 try-catch 块中被调用.
This method is called within try-catch block.
当应用程序已经通过调用 BackgroundMediaPlayer.Current
启动 IBackgroundTask
时会发生这种情况(在调用 RequestProductPurchaseAsync
几秒钟后发生).
It happens when application already start IBackgroundTask
by calling for BackgroundMediaPlayer.Current
(happens after few seconds after call RequestProductPurchaseAsync
).
如果我在启动应用程序后调用 RequestProductPurchaseAsync
而不调用 BackgroundMediaPlayer.Current
,它可以正常工作.
If I call RequestProductPurchaseAsync
after start app without calling BackgroundMediaPlayer.Current
, it works normally.
这种行为的原因是什么?有一些方法可以解决这个问题吗?
What the reason of this behaviour? There are some ways to solve this problem?
推荐答案
我也遇到了同样的问题,app只是崩溃了,没有抛出异常.发生在 CurrentAppSimulator
和 CurrentApp
上.
I am having the same problem, app just crashes, no exception thrown. Happens with CurrentAppSimulator
as well as CurrentApp
.
我想出的唯一解决方案是杀死后台任务
The only solution I came up with was to kill the Backround task
BackgroundMediaPlayer.Shutdown()
在进行 IAP 之前.确保你在调用关机后也放了一点延迟,有时应用程序在没有它的情况下仍然崩溃(但不那么频繁,所以我猜在关机过程中会有一些延迟)
before making the IAP. Make sure you also put in a bit of delay after calling shutdown, sometimes the app still crashed without it (but not as often, so I guess there was some delay during the shutdown process)
这篇关于WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01