0
我在Universal Windows 10上實現了IBackgroundTask,它的工作原理類似於魅力,但問題是我想啓動關聯的應用程序如果發生某些操作,則轉到該後臺任務。代碼很簡單:如何啓動與我在UWP中創建的IBackgroundTask相關的應用程序Windows 10
public sealed class AdvertisementWatcherTask : IBackgroundTask
{
private IBackgroundTaskInstance backgroundTaskInstance;
public void Run(IBackgroundTaskInstance taskInstance)
{
backgroundTaskInstance = taskInstance;
var details = taskInstance.TriggerDetails as BluetoothLEAdvertisementWatcherTriggerDetails;
if (details != null)
{
//Do things
}
}
}
我已經看到了你可以創建一個這樣的ToastNotification:
Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
Windows.Data.Xml.Dom.XmlNodeList elements = toastXml.GetElementsByTagName("text");
foreach (IXmlNode node in elements)
{
node.InnerText = taskInstance.Task.Name+ " remember to uninstall task if not debugging";
}
ToastNotification notification = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(notification);
通知敬酒做工不錯。它會創建並提示通知,如果您單擊該通知,則會創建此後臺任務的應用程序啓動。這是我想要的行爲,但我想要啓動應用程序而無需點擊任何通知。有什麼辦法可以做到這一點?謝謝。
TL; DR:我想在代碼的某個位置啓動創建後臺任務的應用程序。
恐怕目前沒有API可以實現你要找的東西。 – AbsoluteSith