Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't Insert an event to Calendar Android
    text
    copied!<p>I'm trying to Insert an event to Calendar Using an Intent with the following code:</p> <pre><code>package come.jobfinder.dev; import java.util.Calendar; import org.junit.Test; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Intent; import android.net.Uri; import android.provider.CalendarContract; import android.provider.CalendarContract.Events; public class CalendarWrapper extends Activity { public void syncDataWithCalendar(String workPlace , Calendar date){ //TODO should be a field that user should fill - intreviewLength int intreviewLength = 60;// set it default to be an hour , will be a field user should fill //TODO should be a field that will be sent - position String position = "Product Manager"; //TODO should be a field that will be sent - location String location = "Tel Aviv"; //TODO need to check where to take this argument from long calID = 3; Calendar beginTime = Calendar.getInstance(); beginTime.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH), date.get(Calendar.HOUR), date.get(Calendar.MINUTE)); Calendar endTime = Calendar.getInstance(); endTime.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH), date.get(Calendar.HOUR), date.get(Calendar.MINUTE)+intreviewLength); Intent intent = new Intent(Intent.ACTION_INSERT) .setData(Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) .putExtra(Events.TITLE, "Job Interview with "+workPlace) .putExtra(Events.DESCRIPTION, "Job interview with "+workPlace+" for the position"+position) .putExtra(Events.EVENT_LOCATION, location) .putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY) .putExtra(Intent.EXTRA_EMAIL, "rowan@example.com,trevor@example.com"); startActivity(intent); //return intent; // get the event ID that is the last element in the Uri } } </code></pre> <p>and get the following errors:</p> <pre><code>11-02 21:22:07.580: E/AndroidRuntime(15871): FATAL EXCEPTION: main 11-02 21:22:07.580: E/AndroidRuntime(15871): java.lang.NullPointerException 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.Activity.startActivityForResult(Activity.java:3195) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.Activity.startActivity(Activity.java:3302) 11-02 21:22:07.580: E/AndroidRuntime(15871): at come.jobfinder.dev.CalendarWrapper.syncDataWithCalendar(CalendarWrapper.java:45) 11-02 21:22:07.580: E/AndroidRuntime(15871): at come.jobfinder.dev.UpdateWorkPlace.onClick(UpdateWorkPlace.java:90) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.view.View.performClick(View.java:3627) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.view.View$PerformClick.run(View.java:14329) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Handler.handleCallback(Handler.java:605) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Handler.dispatchMessage(Handler.java:92) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Looper.loop(Looper.java:137) 11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.ActivityThread.main(ActivityThread.java:4511) 11-02 21:22:07.580: E/AndroidRuntime(15871): at java.lang.reflect.Method.invokeNative(Native Method) 11-02 21:22:07.580: E/AndroidRuntime(15871): at java.lang.reflect.Method.invoke(Method.java:511) 11-02 21:22:07.580: E/AndroidRuntime(15871): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980) 11-02 21:22:07.580: E/AndroidRuntime(15871): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747) 11-02 21:22:07.580: E/AndroidRuntime(15871): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Thanks from a head</p> <p>Nir</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload