gpt4 book ai didi

c# - 尝试从 Windows Phone 8.1 : "The application identifier provided is invalid" 中的 backgroundaudiotask 更新 livetile

转载 作者:行者123 更新时间:2023-11-30 14:55:46 27 4
gpt4 key购买 nike

我有一个音乐播放器,想用播放轨道的专辑封面更新 livetile。因此,每次轨道发生变化时,我都会在单独的 Windows Runtine 组件中调用一个方法。该方法如下所示:

public async void CreateLivetile(string albumart, string artist, string trackname)
{
try
{
// constants
string textElementName = "text";
string imageElementName = "image";

// Create a tile update manager
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.EnableNotificationQueue(true);
updater.Clear();

// wide 310x150
var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage03);
tileXml.GetElementsByTagName(textElementName).LastOrDefault().InnerText = string.Format(artist + " - " + trackname);
var image = tileXml.GetElementsByTagName(imageElementName).FirstOrDefault();
if (image != null)
{
var src = tileXml.CreateAttribute("src");
src.Value = albumart;
image.Attributes.SetNamedItem(src);
}

// square 150x150
var squaredTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);
squaredTileXml.GetElementsByTagName(textElementName).FirstOrDefault().InnerText = string.Format(artist + " - " + trackname);
image = squaredTileXml.GetElementsByTagName(imageElementName).LastOrDefault();
if (image != null)
{
var src = squaredTileXml.CreateAttribute("src");
src.Value = albumart;
image.Attributes.SetNamedItem(src);
}

updater.Update(new TileNotification(tileXml));
updater.Update(new TileNotification(squaredTileXml));
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);

// Inform the system that the task is finished.
//_deferral.Complete();
}
}

当方法到达这一行时:

var updater = TileUpdateManager.CreateTileUpdaterForApplication();

我收到这个错误:

The application identifier provided is invalid.

此方法在应用程序(前端)中运行良好...

最佳答案

有解决办法: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/83498107-fe0d-4a8b-93f3-02d484983953/tileupdatemanager-throws-exception?forum=wpdevelop

直接提供ID即可: TileUpdateManager.CreateTileUpdaterForApplication("App")

关于c# - 尝试从 Windows Phone 8.1 : "The application identifier provided is invalid" 中的 backgroundaudiotask 更新 livetile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24659722/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com