Bug 18643 - Adding RemindersMethod.Alert to calendar event causing crash in calendar app.
Summary: Adding RemindersMethod.Alert to calendar event causing crash in calendar app.
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.12.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-03-29 12:12 UTC by Jon Goldberger [MSFT]
Modified: 2017-06-27 00:17 UTC (History)
3 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project (49.89 KB, application/zip)
2014-03-29 12:25 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Comment 1 Jon Goldberger [MSFT] 2014-03-29 12:19:59 UTC
From case:
I have been attempting to create a calendar event in Android that has a reminder programmatically set along with the title, date and time. Using the examples in the Calendar Demo I have been able to create the event, but when I include code to set a 15 minute reminder the event that is created is unstable.

There is no error returned from the app, but when I click the event in the Android Calendar, Calendar crashes.

I believe that the problem is going to be rooted in a reminder being set before the attending status is flagged, but I could be wrong. In an attempt to test this theory I have been searching for a way to pragmatically set the event status to Confirmed. I am unable to find example code or adequate documentation to assist me

http://androidapi.xamarin.com/?link=F%3aAndroid.Provider.EventsStatus.Confirmed

"Documentation for this section has not yet been entered"

http://androidapi.xamarin.com/?link=F%3aAndroid.Provider.CalendarContract%2bEvents%2bInterfaceConsts.StatusConfirmed


* "Documentation for this section has not yet been entered"

* [System.Obsolete("This constant will be removed in the future version. Use Android.Provider.EventsStatus enum directly instead of this field.")]

http://androidapi.xamarin.com/?link=T%3aAndroid.Provider.EventsStatus

"Documentation for this section has not yet been entered"

Any assistance you can provide along this avenue would be greatly appreciated.
-------------------------------------------------------------------
Here is the order of death for CalendarProblem:


· The first screen prompts you with a button to launch the CalendarList activity that allows the user to select which calendar the event will be added to.

· When that calendar is selected the ID is passed to the SetReminder activity where the user can change the time and date of the Event, then set the event with a 15 minute reminder or without a reminder.

· If you then open the Android Calendar program you should see two entries one titled “Calendar Problem – With Reminder” and “Calendar Problem – No Reminder.”

· Selecting the event marked No Reminder won’t cause any issues. If you select “Calendar Problem – With Reminder” the Android Calendar program will crash.
Comment 2 Jon Goldberger [MSFT] 2014-03-29 12:25:44 UTC
Created attachment 6434 [details]
Test Project

I modified this test project from the one that the customer in desk case https://xamarin.desk.com/agent/case/66058 sent to remove a couple of unrelated errors he mentioned after sending the project. I also inserted a couple of console output lines to show the output from the relevant fields.
Comment 3 Jon Goldberger [MSFT] 2014-03-29 12:40:33 UTC
After investigation, I found that commenting out line 79 in SetReminder.cs resolved this issue. 

Line 79:
reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, RemindersMethod.Alert.ToString());

RemindersMethod.Alert does not seem to return the correct value for passing to the CalendarContract. IN addition it seems that CalendarContract.Events.InterfaceConsts.AllowedReminders and CalendarContract.CalendarColumns.AllowedReminders do not return a comma separated list of allowed reminder types from the CalendarContract as the android docs suggest it should:

http://developer.android.com/reference/android/provider/CalendarContract.CalendarColumns.html#ALLOWED_REMINDERS
Comment 4 Jon Goldberger [MSFT] 2014-03-30 20:42:35 UTC
More info:

Changing line 79 to:

reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method,
1);

Also works. In the calendar app on my device (Samsung Galaxy 2), there is only one available reminder type, Alert, which has the enum value of 1. Using a value other than 1 for the second argument above results in no reminder added, however using 1 as the second argument results in an event added with an Alert reminder, same as commenting out the line, which one would assume sets the default reminder method. 

According to the docs the available reminder method values are: Default(0),  Alert(1), Email(2), SMS(3)
However depending on the calendar app on the device some may not be available, thus the need to be able to check the AllowedReminders for a calendar with CalendarContract.CalendarColumns.AllowedReminders or CalendarContract.Events.InterfaceConsts.AllowedReminders.
Comment 5 Sadik Ali 2014-04-02 07:27:00 UTC
I have checked this issue with the help of attached calendar project. I debug application and followed steps mentioned in the bug description.  

When I select “Calendar Problem – With Reminder” the Android Calendar program will crash. 

Device Log: https://gist.github.com/saurabh360/8a7049b2e9bbf5553b18

Build Info:

=== Xamarin Studio ===
Version 4.2.3 (build 60)
Installation UUID: b1fc3b76-cf00-405e-a0a1-3839ac11fe6d

=== Apple Developer Tools ===
Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.Android ===
Version: 4.12.1 (Enterprise Edition)
Android SDK: /Users/apple/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Build Information ===
Release ID: 402030060
Git revision: 30c4afc300c2a39ec5300851357ce02e49dd217e
Xamarin addins: f8a9589b57c2bfab2ccd73c880e7ad81e3ecf044

=== Operating System ===
Mac OS X 10.9.3
Darwin Apples-iMac.local 13.2.0 Darwin Kernel Version 13.2.0
    Mon Mar 24 19:18:06 PDT 2014
    root:xnu-2422.100.10~2/RELEASE_X86_64 x86_64
Comment 6 Jonathan Pryor 2014-04-22 11:56:30 UTC
Is this a port of any Java code? If so, can the original Java code be provided?

@Sadik, @Jon: What Android version is the target device running? I've tried this on my Nexus 5 w/ Android v4.4.2, and it doesn't trigger the error listed in Comment #5.

I thus have to wonder if this depends on the Android target's version.

Furthermore, the stack trace in Comment #5:

> E/AndroidRuntime(26753): java.lang.NumberFormatException: Invalid int: "Alert"
> E/AndroidRuntime(26753): 	at java.lang.Integer.invalidInt(Integer.java:138)
> E/AndroidRuntime(26753): 	at java.lang.Integer.parse(Integer.java:375)
> E/AndroidRuntime(26753): 	at java.lang.Integer.parseInt(Integer.java:366)
> E/AndroidRuntime(26753): 	at java.lang.Integer.parseInt(Integer.java:332)
> E/AndroidRuntime(26753): 	at android.database.MatrixCursor.getInt(MatrixCursor.java:247)
> E/AndroidRuntime(26753): 	at com.android.calendar.EventInfoFragment.initReminders(EventInfoFragment.java:3350)
> E/AndroidRuntime(26753): 	at com.android.calendar.EventInfoFragment$QueryHandler.onQueryComplete(EventInfoFragment.java:4123)
> E/AndroidRuntime(26753): 	at com.android.calendar.AsyncQueryService.handleMessage(AsyncQueryService.java:411)

Apparently Android is trying to parse the string "Alert" as an int, which fails. "Alert" in turn comes from RemindersMethod.Alert, suggesting that the cause is SetReminder.cs:

	reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, RemindersMethod.Alert.ToString());

One quick search for "CalendarContract.Reminders.METHOD" (`InterfaceConsts` is a Xamarin-ism, so remove it when searching for Java members), and we find:

http://developer.android.com/reference/android/provider/CalendarContract.RemindersColumns.html#METHOD
> The alarm method, as set on the server. METHOD_DEFAULT, METHOD_ALERT, METHOD_EMAIL, 
> METHOD_SMS and METHOD_ALARM are possible values; the device will only process METHOD_DEFAULT
> and METHOD_ALERT reminders (the other types are simply stored so we can send the same reminder
> info back to the server when we make changes).

So the value should be e.g. METHOD_ALARM, which -- behold! -- is an int:

http://developer.android.com/reference/android/provider/CalendarContract.RemindersColumns.html#METHOD_ALARM

This would correspond to Android.Provider.CalendarContract.RemindersColumns.MethodAlert:

http://androidapi.xamarin.com/?link=F%3aAndroid.Provider.CalendarContract.RemindersColumns.MethodAlert

Which in turn suggests that SetReminder.cs _should_ do:

	reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int) CalendarContract.RemindersColumns.MethodAlert);
Comment 7 Chris Hardy [MSFT] 2017-06-26 17:59:57 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!