Error Inserting Event into Calendar with Intent

后端 未结 4 1608
离开以前
离开以前 2021-01-20 19:14

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

相关标签:
4条回答
  • 2021-01-20 19:48

    I used Intent intent = new Intent(Intent.ACTION_EDIT); and it seemed to resolve the issue

    0 讨论(0)
  • 2021-01-20 19:57

    Calender App may not be installed in some devices. So enclose within try catch block to check.

    Calendar startTymVar = Calendar.getInstance();
    startTymVar.set(2015, 12, 31, 11, 30);
    
    Intent calendarIntentVar = new Intent(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();
    }
    
    0 讨论(0)
  • 2021-01-20 20:02

    Check if there is any activity that resolves this intent

    if (intent.resolveActivity(getPackageManager()) == null) {
    }
    
    0 讨论(0)
  • 2021-01-20 20:12

    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

    0 讨论(0)
提交回复
热议问题