我正在尝试创建一个 Intent 来创建日历活动。下面是代码:
public void onClickCalendarEntry(View view){
Intent calendarIntent = new Intent(Intent.ACTION_INSERT);
calendarIntent.setType("com.android.calendar/events");
calendarIntent.putExtra(Events.TITLE, "Learn Android");
calendarIntent.putExtra(Events.EVENT_LOCATION, "Home");
calendarIntent.putExtra(Events.DESCRIPTION, "Learn activities");
//Setting dates
GregorianCalendar calDate = new GregorianCalendar(2012,12,2);
calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
calDate.getTimeInMillis());
calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis());
Log.d(tag, "Before startActivity()");
startActivity(calendarIntent);
Log.d(tag, "Afte startActivity()");
}
现在下面是 AndroidManifest.exml 提取:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
以下是我收到的错误消息:
12-02 20:27:54.958: D/MainActivity(5512): Before startActivity()
12-02 20:27:54.968: D/AndroidRuntime(5512): Shutting down VM
12-02 20:27:54.978: W/dalvikvm(5512): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
12-02 20:27:54.978: E/AndroidRuntime(5512): FATAL EXCEPTION: main
12-02 20:27:54.978: E/AndroidRuntime(5512): java.lang.IllegalStateException: Could not execute method of the activity
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.view.View$1.onClick(View.java:2168)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.view.View.performClick(View.java:2552)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.view.View$PerformClick.run(View.java:9229)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.os.Handler.handleCallback(Handler.java:587)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.os.Looper.loop(Looper.java:130)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.app.ActivityThread.main(ActivityThread.java:3701)
12-02 20:27:54.978: E/AndroidRuntime(5512): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 20:27:54.978: E/AndroidRuntime(5512): at java.lang.reflect.Method.invoke(Method.java:507)
12-02 20:27:54.978: E/AndroidRuntime(5512): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
12-02 20:27:54.978: E/AndroidRuntime(5512): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
12-02 20:27:54.978: E/AndroidRuntime(5512): at dalvik.system.NativeStart.main(Native Method)
12-02 20:27:54.978: E/AndroidRuntime(5512): Caused by: java.lang.reflect.InvocationTargetException
12-02 20:27:54.978: E/AndroidRuntime(5512): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 20:27:54.978: E/AndroidRuntime(5512): at java.lang.reflect.Method.invoke(Method.java:507)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.view.View$1.onClick(View.java:2163)
12-02 20:27:54.978: E/AndroidRuntime(5512): ... 11 more
12-02 20:27:54.978: E/AndroidRuntime(5512): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT typ=com.android.calendar/events (has extras) }
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.app.Activity.startActivityForResult(Activity.java:2827)
12-02 20:27:54.978: E/AndroidRuntime(5512): at android.app.Activity.startActivity(Activity.java:2933)
12-02 20:27:54.978: E/AndroidRuntime(5512): at com.example.sendingusertoanotherapp.MainActivity.onClickCalendarEntry(MainActivity.java:88)
12-02 20:27:54.978: E/AndroidRuntime(5512): ... 14 more
谁能帮我理解这里的问题是什么?谢谢。
关于,Sudipta Deb。