Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4624038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:04:24+00:00 2026-05-22T03:04:24+00:00

I am trying to build a calendar app for Android. I am struck in

  • 0

I am trying to build a calendar app for Android. I am struck in the middle. I have managed to retrieve the information such as time and task from the user.

I don’t know how to add this into android events. Is there anything like setEvent or something similar?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:04:25+00:00Added an answer on May 22, 2026 at 3:04 am

    Nope, it is more complicated than just calling a method, if you want to transparently add it into the user’s calendar.

    You’ve got a couple of choices;

    1. Calling the intent to add an event on the calendar

      This will pop up the Calendar application and let the user add the event. You can pass some parameters to prepopulate fields:

      Calendar cal = Calendar.getInstance();              
      Intent intent = new Intent(Intent.ACTION_EDIT);
      intent.setType("vnd.android.cursor.item/event");
      intent.putExtra("beginTime", cal.getTimeInMillis());
      intent.putExtra("allDay", false);
      intent.putExtra("rrule", "FREQ=DAILY");
      intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
      intent.putExtra("title", "A Test Event from android app");
      startActivity(intent);
      

      Or the more complicated one:

    2. Get a reference to the calendar with this method

      (It is highly recommended not to use this method, because it could break on newer Android versions):

      private String getCalendarUriBase(Activity act) {
      
          String calendarUriBase = null;
          Uri calendars = Uri.parse("content://calendar/calendars");
          Cursor managedCursor = null;
          try {
              managedCursor = act.managedQuery(calendars, null, null, null, null);
          } catch (Exception e) {
          }
          if (managedCursor != null) {
              calendarUriBase = "content://calendar/";
          } else {
              calendars = Uri.parse("content://com.android.calendar/calendars");
              try {
                  managedCursor = act.managedQuery(calendars, null, null, null, null);
              } catch (Exception e) {
              }
              if (managedCursor != null) {
                  calendarUriBase = "content://com.android.calendar/";
              }
          }
          return calendarUriBase;
      }
      

      and add an event and a reminder this way:

      // get calendar
      Calendar cal = Calendar.getInstance();     
      Uri EVENTS_URI = Uri.parse(getCalendarUriBase(this) + "events");
      ContentResolver cr = getContentResolver();
      
      // event insert
      ContentValues values = new ContentValues();
      values.put("calendar_id", 1);
      values.put("title", "Reminder Title");
      values.put("allDay", 0);
      values.put("dtstart", cal.getTimeInMillis() + 11*60*1000); // event starts at 11 minutes from now
      values.put("dtend", cal.getTimeInMillis()+60*60*1000); // ends 60 minutes from now
      values.put("description", "Reminder description");
      values.put("visibility", 0);
      values.put("hasAlarm", 1);
      Uri event = cr.insert(EVENTS_URI, values);
      
      // reminder insert
      Uri REMINDERS_URI = Uri.parse(getCalendarUriBase(this) + "reminders");
      values = new ContentValues();
      values.put( "event_id", Long.parseLong(event.getLastPathSegment()));
      values.put( "method", 1 );
      values.put( "minutes", 10 );
      cr.insert( REMINDERS_URI, values );
      

      You’ll also need to add these permissions to your manifest for this method:

      <uses-permission android:name="android.permission.READ_CALENDAR" />
      <uses-permission android:name="android.permission.WRITE_CALENDAR" />
      

    Update: ICS Issues

    The above examples use the undocumented Calendar APIs, new public Calendar APIs have been released for ICS, so for this reason, to target new android versions you should use CalendarContract.

    More infos about this can be found at this blog post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying build an App Engine connected Android application and am having some problems
I'm trying to build a calendar that looks like Android internal Calendar. The thing
Okay I have been racking my brain trying to build a JSON array from
I'm trying to build an android RSS reader app but I keep getting a
I'm trying to build a little calendar in JavaScript. I have my dates working
I'm trying to build a little calendar app sort of like Google Calendar. I'm
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build a method which returns the shortest path from one node to
I'm trying to read a calendar feed from http://meetup.com/ , but it seems that
I'm trying to build a quick overview that shows the upcoming calendar week. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.