Permission to use my calendar in Android Xamarin -
i trying add event calendar in android app made in xamarin. keep getting error "requires android.permission.read_calendar or android.permission.write_calendar" . can please me this? here code..... thank you!!!
using system; using myapp; using myapp.droid; using android.content; using android.provider; using xamarin.forms; [assembly: xamarin.forms.dependency (typeof (calendarmanager))] namespace myapp.droid { public class calendarmanager : icalendarmanager { public calendarmanager () {} //public const string write_calendar = "android.permission.write_calendar"; //public const string read_calendar = "android.permission.read_calendar"; //android.permission.write_calendar public void saveevent(datetime start, datetime end, string title, string notes, string location, bool allday) { contentvalues eventdetails = new contentvalues(); eventdetails.put (calendarcontract.events.interfaceconsts.dtstart, start.touniversaltime ().tostring ()); eventdetails.put (calendarcontract.events.interfaceconsts.dtend, end.touniversaltime ().tostring ()); eventdetails.put(calendarcontract.events.interfaceconsts.title, title); eventdetails.put(calendarcontract.events.interfaceconsts.eventlocation, location); eventdetails.put(calendarcontract.events.interfaceconsts.allday, allday); eventdetails.put(calendarcontract.events.interfaceconsts.eventtimezone, "utc"); eventdetails.put(calendarcontract.events.interfaceconsts.eventendtimezone, "utc"); var ctx = forms.context; ctx.contentresolver.insert(calendarcontract.events.contenturi, eventdetails); } } }
in androidmanifest.xml, have declare permissions app requires, android can notify user when install app.
setting read calendar , write calendar permissions should resolve issue.
Comments
Post a Comment