pengwang
pengwang

Reputation: 19956

android calendar

ComponentName componentName = new ComponentName("com.android.calendar",
        "com.android.calendar.LaunchActivity");
if (componentName != null) {
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
    // com.android.providers.calendar.CalendarProvider
    intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

    intent.setComponent(componentName);
    startActivity(intent);
} else {
    Log.i("", "98979");
}

LogCat returns the following error:

ERROR/AndroidRuntime(601): Caused by: android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.android.calendar/com.android.calendar.LaunchActivity};
have you declared this activity in your AndroidManifest.xml?

What is the new calendar address or package?

Upvotes: 4

Views: 4833

Answers (3)

hpAndro
hpAndro

Reputation: 178

try this for open mobile's calendar...

int sdk = android.os.Build.VERSION.SDK_INT;
int ICE_CREAM_BUILD_ID = android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
if(sdk < ICE_CREAM_BUILD_ID) {
    // all SDK below ice cream sandwich
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra("beginTime", startTime);
    intent.putExtra("endTime", endTime);
    intent.putExtra("title", title);
    intent.putExtra("description", description);
    intent.putExtra("eventLocation", location);
    intent.putExtra("allDay", isAllDay);
    startActivity(intent);
} else {
    // ice cream sandwich and above
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime);
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime);
    intent.putExtra(Events.TITLE, title);
    intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
    intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY , isAllDay);
    intent.putExtra(Events.DESCRIPTION, description);
    intent.putExtra(Events.EVENT_LOCATION, location);

    startActivity(intent);
}

Upvotes: 3

djk
djk

Reputation: 3691

try this,

its working for me, to open google Calendar, not phone's

 Intent i = new Intent();

//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it    depends on the phone...)
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");

 //less than Froyo
 cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity");

i.setComponent(cn);
startActivity(i);

i am also searching to open phones calendar

Upvotes: 3

Leif
Leif

Reputation: 1

This only works for generic android phones. On phones where the manufacturer have implemented their own calendar the class name of the calendar classes will be different.

Upvotes: 1

Related Questions