How to launch Android Calendar application using Intent (Froyo)

后端 未结 6 1385
被撕碎了的回忆
被撕碎了的回忆 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:28

    You can open Calendar View by two means:

    1) by particular date 2) by particular event

    For this you have to add following two permissions

      
      
    

    1) by particular date:

    Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
    builder.appendPath("time");
    ContentUris.appendId(builder, Calendar.getInstance().getTimeInMillis());
    Intent intent = new Intent(Intent.ACTION_VIEW)
        .setData(builder.build());
    startActivity(intent);
    

    2) by particular event:

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

    Note: CalendarContract content provider was added to the Android SDK in API Level 14. For more information you can visit this link

提交回复
热议问题