2009-12-22 144 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); 
}