(Windows 10)在uwp应用程序中处理来电
我需要做一些任务时,手机有来电,但目前,我不能 我已经阅读了一个关于当一个无法识别的来电到达这个链接时要触发的后台任务的示例,我已经尝试过了,但我的后台任务并没有收到任何东西 以下是注册后台任务代码:(Windows 10)在uwp应用程序中处理来电,uwp,phone-call,background-task,Uwp,Phone Call,Background Task,我需要做一些任务时,手机有来电,但目前,我不能 我已经阅读了一个关于当一个无法识别的来电到达这个链接时要触发的后台任务的示例,我已经尝试过了,但我的后台任务并没有收到任何东西 以下是注册后台任务代码: private async void RegisterTask() { string phoneObsName = "phoneObsName"; var access = await BackgroundExecutionManager.RequestAc
private async void RegisterTask()
{
string phoneObsName = "phoneObsName";
var access = await BackgroundExecutionManager.RequestAccessAsync();
if (access != BackgroundAccessStatus.Denied &&
access != BackgroundAccessStatus.Unspecified)
{
// Create a new background task builder.
BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
// Create a new Phone Trigger.
PhoneTrigger trigger = new PhoneTrigger(PhoneTriggerType.CallOriginDataRequest, false);
// Associate the phone trigger with the background task builder.
taskBuilder.SetTrigger(trigger);
// Specify the background task to run when the trigger fires.
taskBuilder.TaskEntryPoint = typeof(BackgroundStuff.PhoneCallBackgroundTask).ToString(); ;
// Name the background task.
taskBuilder.Name = phoneObsName;
// Register the background task.
BackgroundTaskRegistration taskRegistration = taskBuilder.Register();
//UpdateBackgroundTaskUIState(true);
//rootPage.NotifyUser("Registered Caller ID background task", NotifyType.StatusMessage);
}
else
{
//rootPage.NotifyUser("Background agent access denied", NotifyType.ErrorMessage);
}
}
请帮助我解决问题。您在何时何地调用RegisterTask方法?另外,您是否已将后台任务添加到项目清单中?是的,我有后台任务,支持任务类型为项目清单上的电话呼叫。我在OnLaunched()的末尾调用App.xaml.cs上的RegisterTask。您在何时何地调用RegisterTask方法?另外,您是否已将后台任务添加到项目清单中?是的,我有后台任务,支持任务类型为项目清单上的电话呼叫。我在OnLaunched()的末尾调用App.xaml.cs上的RegisterTask。