2009-12-22 109 views
4
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返回以下错误:Android的Google日历

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?

什么是新的日历地址或包?

+2

嗨,你可以编辑你的问题,并正确地格式化代码段吗?这里的堆栈溢出语法参考:http://stackoverflow.com/editing-help – 2009-12-22 21:48:59

+0

请帮助这个线程也 http://stackoverflow.com/questions/37658179/android-calendar-show-continuous-event-that-extends - 用于-2或更多的天 – 2016-06-06 13:01:10

回答

3

试试这个,

其工作对我来说,打开谷歌日历,没有手机的

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); 

我也搜索打开手机日历

1

这只适用于通用Android手机。在制造商已经实施其自己的日历的电话上,日历类的类名将是不同的。

3

尝试一下本作开放移动的日历..

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); 
}