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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:59:33+00:00 2026-06-08T02:59:33+00:00

I have tried to use this code (as I have seen in a tutorial)

  • 0

I have tried to use this code (as I have seen in a tutorial)

Calendar cal = Calendar.getInstance();  
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", dateStart.getTime());
intent.putExtra("allDay", false);
intent.putExtra("rrule", "FREQ=DAILY");
intent.putExtra("endTime", dateEnd.getTime());
intent.putExtra("hasAlarm", 1);
startActivity(intent);

to add an event on integrated Calendar in android

But as I wrote get a NullPointerException error on the line

startActivity(intent);

With this stack

07-17 19:12:05.469: W/System.err(30939): java.lang.NullPointerException
07-17 19:12:05.469: W/System.err(30939):    at android.app.Activity.startActivityForResult(Activity.java:2827)
07-17 19:12:05.469: W/System.err(30939):    at android.app.Activity.startActivity(Activity.java:2933)
07-17 19:12:05.469: W/System.err(30939):    at myapplication.beachparty.utility.MyUtility.addEventToCalendar(MyUtility.java:44)
07-17 19:12:05.469: W/System.err(30939):    at myapplication.beachparty.it.PartyDetails$2.onClick(PartyDetails.java:114)
07-17 19:12:05.469: W/System.err(30939):    at android.view.View.performClick(View.java:2485)
07-17 19:12:05.479: W/System.err(30939):    at android.view.View$PerformClick.run(View.java:9080)
07-17 19:12:05.479: W/System.err(30939):    at android.os.Handler.handleCallback(Handler.java:587)
07-17 19:12:05.499: W/System.err(30939):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-17 19:12:05.499: W/System.err(30939):    at android.os.Looper.loop(Looper.java:130)
07-17 19:12:05.499: W/System.err(30939):    at android.app.ActivityThread.main(ActivityThread.java:3687)
07-17 19:12:05.499: W/System.err(30939):    at java.lang.reflect.Method.invokeNative(Native Method)
07-17 19:12:05.499: W/System.err(30939):    at java.lang.reflect.Method.invoke(Method.java:507)
07-17 19:12:05.499: W/System.err(30939):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-17 19:12:05.499: W/System.err(30939):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-17 19:12:05.499: W/System.err(30939):    at dalvik.system.NativeStart.main(Native Method)
07-17 19:12:07.069: W/System.err(30939): java.lang.NullPointerException
07-17 19:12:07.069: W/System.err(30939):    at android.app.Activity.startActivityForResult(Activity.java:2827)
07-17 19:12:07.069: W/System.err(30939):    at android.app.Activity.startActivity(Activity.java:2933)
07-17 19:12:07.069: W/System.err(30939):    at myapplication.beachparty.utility.MyUtility.addEventToCalendar(MyUtility.java:44)
07-17 19:12:07.069: W/System.err(30939):    at myapplication.beachparty.it.PartyDetails$3.onClick(PartyDetails.java:128)
07-17 19:12:07.069: W/System.err(30939):    at android.view.View.performClick(View.java:2485)
07-17 19:12:07.069: W/System.err(30939):    at android.view.View$PerformClick.run(View.java:9080)
07-17 19:12:07.069: W/System.err(30939):    at android.os.Handler.handleCallback(Handler.java:587)
07-17 19:12:07.069: W/System.err(30939):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-17 19:12:07.069: W/System.err(30939):    at android.os.Looper.loop(Looper.java:130)
07-17 19:12:07.069: W/System.err(30939):    at android.app.ActivityThread.main(ActivityThread.java:3687)
07-17 19:12:07.069: W/System.err(30939):    at java.lang.reflect.Method.invokeNative(Native Method)
07-17 19:12:07.069: W/System.err(30939):    at java.lang.reflect.Method.invoke(Method.java:507)
07-17 19:12:07.069: W/System.err(30939):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-17 19:12:07.079: W/System.err(30939):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-17 19:12:07.079: W/System.err(30939):    at dalvik.system.NativeStart.main(Native Method)


dateStart

ad
dateEnd are
Date objects that indicates the day, mouth, year and time of event

I have tried also to change these lines with

intent.putExtra("beginTime", cal.getTimeInMillis());

and

intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);

What is wrong?

NB
I have tried the code on Emulator and Samsung Galaxy. And use the API level 10 (GingerBread)

  • 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-08T02:59:35+00:00Added an answer on June 8, 2026 at 2:59 am

    You cannot start this activity from another class simply invoking the method,

    the line

    startActivity(intent);
    

    cause NullPointerException because haven’t a context

    you should pass the Context in the method and write

    mycontext.startActivity(intent);
    

    In this way should works.

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

Sidebar

Related Questions

hy all, i tryed to use this code as seen on a tutorial, but
I have tried to use the following snippet of code: int main() { string
I am trying to use std::shared_ptr in my code. I have seen there have
I have seen a few .NET apps use .db files. I am not new
I have tried to use mysql fulltext search in my intranet. I wanted to
I have heard about JNI and have tried to use it. What I would
Have you tried to use SharePoint with version control such as Perforce (or Subversion),
I use maven 3.0.3 and have tried to generate pom for third-party jar like
I have to use oracle database in android. I have tried to work as
I want to use a variable in a string. I have tried to do

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.