我的WindowsPhoneApp日历存在问题
我已在我的应用程序中成功创建日历和约会。 Uri链接被处理并适用于整个应用程序。
当我在系统日历中点击预约时,无论是否提供了appointment.uri,我的应用程序都会被终止。
同样的Uri通过Uri Schemes App工作得很好,或者如果它是在appointment.details中提供的,但是在这个选项中我不知道如何掩盖这个URI。
创建日历代码:
private AppointmentCalendar currentAppCalendar;
private const string calendarName = "nowapka";
public async Task<AppointmentCalendar> CreateCalendar()
{
AppointmentStore AppStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
IReadOnlyList<AppointmentCalendar> appCalendars =
await AppStore.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.IncludeHidden);
AppointmentCalendar appCalendar = null;
// Apps can create multiple calendars. Here app creates only one.
if (appCalendars.Count == 0)
{
appCalendar = await AppStore.CreateAppointmentCalendarAsync(calendarName);
}
else
{
appCalendar = appCalendars[0];
}
appCalendar.OtherAppReadAccess = AppointmentCalendarOtherAppReadAccess.Full;
appCalendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.SystemOnly;
// This app will show the details for the appointment. Use System to let the system show the details.
appCalendar.SummaryCardView = AppointmentSummaryCardView.App;
await appCalendar.SaveAsync();
//await ClearCalendar(appCalendar);
return appCalendar;
}
public async Task AddAppointmentToCalendar()
{
if (currentAppCalendar == null) currentAppCalendar = await CreateCalendar();
Appointment newAppointment = new Appointment();
try
{
newAppointment.StartTime = new DateTimeOffset(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Today.Hour+1, DateTime.Today.Minute+10, DateTime.Today.Second, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now));
newAppointment.Subject = string.Format("test nowaapka ");
newAppointment.Duration = new TimeSpan(1, 0, 0);
newAppointment.AllDay = false;
newAppointment.Reminder = new TimeSpan(24, 0, 0);
newAppointment.Details = "nowapka://pivotpage/?number=2138138";
newAppointment.Sensitivity = AppointmentSensitivity.Private;
newAppointment.BusyStatus = AppointmentBusyStatus.Busy;
newAppointment.Uri = new Uri("nowapka://pivotpage/?number=2138138");
await currentAppCalendar.SaveAppointmentAsync(newAppointment);
}
catch (Exception error)
{
}
}
在应用代码中处理uri:
protected override async void OnActivated(IActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active.
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page.
rootFrame = new Frame();
// Associate the frame with a SuspensionManager key.
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
// TODO: Change this value to a cache size that is appropriate for your application.
rootFrame.CacheSize = 1;
// Set the default language
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// Restore the saved session state only when appropriate.
try
{
await SuspensionManager.RestoreAsync();
}
catch (SuspensionManagerException)
{
// Something went wrong restoring state.
// Assume there is no state and continue.
}
}
// Place the frame in the current Window.
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}
rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter.
if (!rootFrame.Navigate(typeof(PivotPage), e))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active.
Window.Current.Activate();
base.OnActivated(e);
}
有人可以帮忙解决这个问题吗?也许它是windowsPhone日历的常见问题?