我是 Android 开发新手。我正在使用以下代码在我的 Android 应用程序中添加事件日历。
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);
但出现以下错误:
02-21 12:33:38.262: E/AndroidRuntime(404): FATAL EXCEPTION: main
02-21 12:33:38.262: E/AndroidRuntime(404): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event (has extras) }
02-21 12:33:38.262: E/AndroidRuntime(404): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.app.Activity.startActivityForResult(Activity.java:2817)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.app.Activity.startActivity(Activity.java:2923)
02-21 12:33:38.262: E/AndroidRuntime(404): at com.infrasoft.elara.HomeActivity$1.onClick(HomeActivity.java:36)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.view.View.performClick(View.java:2408)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.view.View$PerformClick.run(View.java:8816)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.os.Handler.handleCallback(Handler.java:587)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.os.Handler.dispatchMessage(Handler.java:92)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.os.Looper.loop(Looper.java:123)
02-21 12:33:38.262: E/AndroidRuntime(404): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-21 12:33:38.262: E/AndroidRuntime(404): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 12:33:38.262: E/AndroidRuntime(404): at java.lang.reflect.Method.invoke(Method.java:521)
02-21 12:33:38.262: E/AndroidRuntime(404): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-21 12:33:38.262: E/AndroidRuntime(404): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-21 12:33:38.262: E/AndroidRuntime(404): at dalvik.system.NativeStart.main(Native Method)
AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<activity
android:name=".CalendarActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.INSERT" />
<category android:name="android.intent.category.APP_CALENDAR" />
<data android:mimeType="vnd.android.cursor.item/event" />
</intent-filter>
</activity>
请告诉我有什么问题。
提前致谢。