Error Inserting Event Into Calendar With Intent
I'm trying to insert events to the calendar from a fragment, but I keep getting an error that no activity is found to handle Intent. Here's the error - android.content.ActivityN
Solution 1:
I used Intent intent = new Intent(Intent.ACTION_EDIT); and it seemed to resolve the issue
Solution 2:
Calender App may not be installed in some devices. So enclose within try catch block to check.
CalendarstartTymVar= Calendar.getInstance();
startTymVar.set(2015, 12, 31, 11, 30);
IntentcalendarIntentVar=newIntent(Intent.ACTION_INSERT)
.setData(CalendarContract.Events.CONTENT_URI)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTymVar.getTimeInMillis())
.putExtra(CalendarContract.Events.TITLE, "New Year")
.putExtra(CalendarContract.Events.DESCRIPTION, "Hav ful fun");
try
{
startActivity(calendarIntentVar);
}
catch (ActivityNotFoundException ErrVar)
{
Toast.makeText(this, "Install Calender App", Toast.LENGTH_LONG).show();
}
Solution 3:
if you already know the information which it looks like you do you do not need to launch the calendar app, simply just insert the event into the database see adding events
Also looking at the docs APP_CALENDAR
is only used with ACTION_MAIN
not ACTION_INSERT
Solution 4:
Check if there is any activity that resolves this intent
if (intent.resolveActivity(getPackageManager()) == null) {
}
Post a Comment for "Error Inserting Event Into Calendar With Intent"