How to using intents to view calendar data?

前端 未结 3 555
一个人的身影
一个人的身影 2020-12-06 14:52

I made this code:

long eventID = 208;
Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
Intent intent = new Intent(Intent.ACTION_VIEW)
   .s         


        
相关标签:
3条回答
  • 2020-12-06 15:06

    This may help you!!! http://developer.android.com/guide/topics/providers/calendar-provider.html

    0 讨论(0)
  • 2020-12-06 15:20

    on Android 4.2.2, seems still having the same problem. Is it the correct behavior, or some thing missing here?

    1. got the event id through Instances.query(Globals.sContext.getContentResolver(), proj, begin, end); proj= String[]{Instances.EVENT_ID, Instances.BEGIN, Instances.END...};

    2. use the even id to view the event in calendar app.

    tried with code (from http://developer.android.com/guide/topics/providers/calendar-provider.html), it still shows December 31 1969 on the 'Detail view' opened by the 'intent'; and shows current date in the 'Edit event' form if clicking on the the event on the 'Detail view' of the calendar.

    ...

    Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
    
    Intent intent = new Intent(Intent.ACTION_VIEW)
    
       .setData(uri);
    
    startActivity(intent);
    

    and still does not work even with the:

    intent.putExtra("beginTime", from);
    intent.putExtra("endTime", till);  //'from', 'till' is the mills got from the Instances.BEGIN/END fields from the query
    

    EDIT: the following code works. only difference is using the define CalendarContract.EXTRA_EVENT_BEGIN_TIME

    Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);
    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, from);
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, till);
    startActivity(intent);
    
    0 讨论(0)
  • 2020-12-06 15:24

    You have to add the event begin & end time to intent's extra data :

    intent.putExtra("beginTime", beginMilliTS);
    intent.putExtra("endTime", endMilliTS);
    

    I got this working by using the values from "begin" and "end" field of an event instance. This should work too with "dtstart" and "dtend" field from an event.

    0 讨论(0)
提交回复
热议问题