How to launch Android Calendar application using Intent (Froyo)

后端 未结 6 1252
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 02:00

I want to open up the Calendar application from an android application. When i searched online, all i got is to create new events using intent. I could find Intents to open

6条回答
  •  有刺的猬
    2020-12-01 02:14

    Using intents to view calendar data

    Calender Provider offers two different ways to use the VIEW Intent:

    To open the Calendar to a particular date.
    To view an event.
    

    add permissions to manifest

    
    
    

    Here is an example that shows how to open the Calendar to a particular date:

     // A date-time specified in milliseconds since the epoch. 
     long startMillis;
     ...
     Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();   
     builder.appendPath("time");
     ContentUris.appendId(builder, startMillis);
     Intent intent = new Intent(Intent.ACTION_VIEW)
         .setData(builder.build());
       startActivity(intent);
    

    Here is an example that shows how to open an event for viewing:

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

    Is it possible to launch the Calendar to a specific week or day?

    So, now it is possible, but requires min API 14.

    For more details visit http://developer.android.com/guide/topics/providers/calendar-provider.html#intents

提交回复
热议问题