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 6628891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:10:55+00:00 2026-05-25T22:10:55+00:00

I am trying to add a new event into the android calendar. Here is

  • 0

I am trying to add a new event into the android calendar. Here is the code I am using

Intent intent = new Intent(Intent.ACTION_EDIT);
                    intent.setType("vnd.android.cursor.item/event");
                    intent.putExtra("title", event.getSummary());
                    intent.putExtra("description", event.getDescription());
                    intent.putExtra("eventLocation", event.getLocation());
                    intent.putExtra("dtstart", event.getStartDate());
                    if(event.getEndDate() == null)
                    {
                        intent.putExtra("allDay", true);
                    }
                    else
                    {
                        intent.putExtra("dtend", event.getEndDate());
                    }

                    startActivity(intent);

I am implementing this method in a separate class which is not an activity class. So I am extending the activity class here.

When i execute last line startActivity(intent); I am getting java nullpointer exception.

No idea how to proceed.

How could I add a entry in to android calendar?
Thanks

  • 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-25T22:10:56+00:00Added an answer on May 25, 2026 at 10:10 pm

    Are you instantiating your activity class with new? You can not do that. Activity classes must be instantiated by OS in order to be functional.

    Solution:

    You have to have a reference to Context in order to call context.startActivity(..). Pass an instance of context to your class in constructor. Hint: all Activities are Contexts, so just do new MyClass(this) from within an Activity.

    Also, your class does not need to extend Activity.

    • 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
I am trying to add a new menu item to Eclipse's popupmenus. It really
I'm trying to add a new ADO.Net Entity Data Model to an MVC project
Im trying to add an element to a database and then return a new
I'm trying to add a variable within a new variable. My first variable is:
I'm fairly new to JQuery and I'm trying to add multiple form fields for
I am new to wordpress and widgets. I am trying to add another field
Hey there, new to AJAX, JS.. Im trying to add to a Javascript/Ajax search
I'm trying to create a new contact and add it to the AddressBook but
I'm trying to create a new ASP.NET website and add it to my subversion

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.