Android developmentAndroid tutorial

How to add calendar events in Android?

How to add calendar events in Android
689views

Hii developer in this Article I am sharing how to add Event in google calendar throws your App just Click on Button. Add your App event to google calendar App.  using Android Intent you can pass your app data to google calendar App. like Event title, event start time, event end time,  Event Description, more. there is an easy android solution to add calendar events in Android. Read More Android tutorial

Let’s Start How to add calendar events in Android?

follow this method to implement Android add calender event in android

 @SuppressLint({"NewApi", "LocalSuppress"})
    public void AddEvent(String Start, String EndDate){
        String Title = Event_DetTitle.getText().toString().trim();
        String Des = Event_DetDescription.getText().toString().trim();
        String Locations = Event_DetLocation.getText().toString().trim();

        Intent intent = new Intent(Intent.ACTION_INSERT)
                .setData(CalendarContract.Events.CONTENT_URI)
                .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, Instant.parse(Start).toEpochMilli())
                .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, Instant.parse(EndDate).toEpochMilli())
                .putExtra(CalendarContract.Events.TITLE, Title)
                .putExtra(CalendarContract.Events.DESCRIPTION, Des)
                .putExtra(CalendarContract.Events.EVENT_LOCATION,Locations )
                .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY);
               .putExtra(Intent.EXTRA_EMAIL, "abc@example.com,codeplayon@example.com");

        startActivity(intent);
    }

 

 

Welcome to my blog! I’m Ritu Malik, and here at Codeplayon.com, we are dedicated to delivering timely and well-researched content. Our passion for knowledge shines through in the diverse range of topics we cover. Over the years, we have explored various niches such as business, finance, technology, marketing, lifestyle, website reviews and many others.