0

I can open a Android event from my activity using the Events.CONTENT_URI intent. I can edit the opened event in the Event Edit screen. However, when I try to add an attachment to the event, it crashes with NullPointerException:

Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, event_id);
Intent intent = new Intent(Intent.ACTION_VIEW).setData(uri);
intent.putExtra("beginTime", startMillis);
intent.putExtra("endTime", endMillis);
startActivity(intent);

When I add an attachment in the Android Event Edit screen, the Android Event Edit screen crashes with the following error:

03-08 22:57:39.711: E/AndroidRuntime(18646): FATAL EXCEPTION: main
03-08 22:57:39.711: E/AndroidRuntime(18646): Process: com.google.android.calendar, PID: 18646
03-08 22:57:39.711: E/AndroidRuntime(18646): java.lang.NullPointerException: Attempt to invoke interface method 'void com.android.calendar.ActivityResultNotifications$ActivityResultNotifierActivity.registerActivityResultListener(com.android.calendar.ActivityResultNotifications$ActivityResultListener)' on a null object reference
03-08 22:57:39.711: E/AndroidRuntime(18646):    at com.google.android.calendar.event.edit.segment.AttachmentsEditSegment.registerForActivityResult(AttachmentsEditSegment.java:522)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at com.google.android.calendar.event.edit.segment.AttachmentsEditSegment.openFilePicker(AttachmentsEditSegment.java:113)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at com.google.android.calendar.event.edit.segment.AttachmentsEditSegment.onClick(AttachmentsEditSegment.java:102)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.view.View.performClick(View.java:4756)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.view.View$PerformClick.run(View.java:19749)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.os.Handler.handleCallback(Handler.java:739)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.os.Handler.dispatchMessage(Handler.java:95)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.os.Looper.loop(Looper.java:135)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at android.app.ActivityThread.main(ActivityThread.java:5221)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at java.lang.reflect.Method.invoke(Native Method)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at java.lang.reflect.Method.invoke(Method.java:372)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-08 22:57:39.711: E/AndroidRuntime(18646):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

I would appreciate it if anyone could give me some idea.

Thanks, Cow.

cowcow
  • 1
  • 1
  • You may be making mistake in `uri` – Apurva Mar 08 '15 at 12:45
  • Could you please explain in more details what you mean " making mistake in uri"? – cowcow Mar 08 '15 at 12:54
  • `Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, event_id);` could be wrong, everything else looks alright. – Apurva Mar 08 '15 at 12:56
  • possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Simon Mar 08 '15 at 12:59
  • I know what is Null pointer exception. When you said "Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, event_id);", please let me know what is the correct value? – cowcow Mar 08 '15 at 13:12
  • What is the value of event_id? – Ben Mar 08 '15 at 13:30
  • The same NullPointerException happens with the official Google Calendar app, when trying to add an attachment from Google Drive... (I'm on 5.0 Moto X 2014). Edit: It seems it depends on how I get to the Event... If I browse and open the event, it works... if I get to the Event from the search results, it fails as above. – julianjm Apr 05 '15 at 11:25

0 Answers0