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

  • Home
  • SEARCH
  • 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 7726071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:07:15+00:00 2026-06-01T05:07:15+00:00

I can set the event on the calendar on my device by using this

  • 0

I can set the event on the calendar on my device by using this code:

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", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);

Now it displays a popup screen so the user can decide to set this event or not, so are there any way to make it automatically ? i mean i can set this event or cancel it by programing, not by waiting the touch from user.
Like the way i set the alarm clock, after i startActivity(intent), it was set automatically (not display a popup alarm clock for setup).

  • 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-06-01T05:07:17+00:00Added an answer on June 1, 2026 at 5:07 am

    u can add event on calendar using this code

    try
    {
        Calendar cal = Calendar.getInstance();
        String[] timedevide = scheduletime.split(":");
    
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
        cal.get(Calendar.DAY_OF_MONTH), 
                Integer.parseInt(timedevide[0]), 
                Integer.parseInt(timedevide[1]), 00);
    
        Uri EVENTS_URI = Uri.parse(getCalendarUriBase(ctx) + "events");
        ContentResolver cr = ctx.getContentResolver();
    
        // event insert
        ContentValues values = new ContentValues();
        values.put("calendar_id", 1);
        values.put("title", title);
        values.put("allDay", 0);
        values.put("dtstart", cal.getTimeInMillis());
        values.put("dtend", cal.getTimeInMillis() + 60 * 60 * 1000);
        values.put("description", description);
        values.put("visibility", 0);
        values.put("hasAlarm", 1);
        Uri event = cr.insert(EVENTS_URI, values);
        addKeyToPreference(Long.parseLong(event.getLastPathSegment()));
        // reminder insert
        Uri REMINDERS_URI = Uri.parse(getCalendarUriBase(ctx) + "reminders");
        values = new ContentValues();
        values.put("event_id", Long.parseLong(event.getLastPathSegment()));
        values.put("method", 1);
        values.put("minutes", mTotalMinute);
        cr.insert(REMINDERS_URI, values);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    
    
    
    private String getCalendarUriBase(Activity activity) {
    
        String calendarUriBase = null;
        Uri calendars = Uri.parse("content://calendar/calendars");
        Cursor managedCursor = null;
        try {
            managedCursor = activity.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 = activity.managedQuery(calendars, null, null, null, null);
            } catch (Exception e) {
            }
            if (managedCursor != null) {
                calendarUriBase = "content://com.android.calendar/";
            }
        }
        return calendarUriBase;
    }
    

    UPDATE

    Managed query is deprecated Now

    Android 4.0 (API Level 14) added a CalendarContract ContentProvider.

    hope this helps

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

Sidebar

Related Questions

I am trying to add calendar event using the below code in my android
How can you set the event listener for a Spinner when the selected item
How can I set an event handler (such as keydown ) to entire solution,
In XAML you can do <TabItem Selector.Selected=myEvenHandler></TabItem> to set the event handler for when
I can set data in JTable constructor, and then user can change this data
I'm using the following code to create an event, and display a popup asking
I'm using Jason Moon's Calendar Script to allow users to set the date of
I run a fairly active student blog that uses this event calendar plugin to
In my app, I want a functionality to create calendar event. I open new
I have developing an App where the user can create event and set notification

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.