WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃

WP8.1 application crashes on calling RequestProductPurchaseAsync(WP8.1 应用程序在调用 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只是崩溃了,没有抛出异常.发生在 CurrentAppSimulatorCurrentApp 上.

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 时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)