在Android应用程序中添加googlecalendar事件

时间:2011-12-21 15:08:21

标签: android

我是Android编程的新手,并一直试图通过Android应用程序将事件添加到谷歌日历。我在网上找到了一个很好的例子但似乎无法让代码运行,因为一旦模拟器启动,应用程序就会崩溃。我正在模仿ANDROID DEVICE上的代码(Google API / API LEVEL 14).Below是代码的URL;

http://roman10.net/src/calendarops.zip

以下是我在logcat中收到的错误;

    12-21 15:24:16.602: D/AndroidRuntime(675): Shutting down VM

12-21 15:24:16.612: W/dalvikvm(675): threadid=1: thread exiting with uncaught exception (group=0x409961f8) 12-21 15:24:16.622: E/AndroidRuntime(675): FATAL EXCEPTION: main 12-21 15:24:16.622: E/AndroidRuntime(675): java.lang.RuntimeException: Unable to start activity ComponentInfo{roman10.tutorial.calendarops/roman10.tutorial.calendarops.Main}: android.database.sqlite.SQLiteException: no such column: displayName: , while compiling: SELECT _id, displayName FROM Calendars 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.access$600(ActivityThread.java:122) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.os.Handler.dispatchMessage(Handler.java:99) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.os.Looper.loop(Looper.java:137) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.main(ActivityThread.java:4340) 12-21 15:24:16.622: E/AndroidRuntime(675): at java.lang.reflect.Method.invokeNative(Native Method) 12-21 15:24:16.622: E/AndroidRuntime(675): at java.lang.reflect.Method.invoke(Method.java:511) 12-21 15:24:16.622: E/AndroidRuntime(675): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 12-21 15:24:16.622: E/AndroidRuntime(675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 12-21 15:24:16.622: E/AndroidRuntime(675): at dalvik.system.NativeStart.main(Native Method) 12-21 15:24:16.622: E/AndroidRuntime(675): Caused by: android.database.sqlite.SQLiteException: no such column: displayName: , while compiling: SELECT _id, displayName FROM Calendars 12-21 15:24:16.622: E/AndroidRuntime(675): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.content.ContentProviderProxy.query(ContentProviderNative.java:358) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.content.ContentResolver.query(ContentResolver.java:310) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Activity.managedQuery(Activity.java:1706) 12-21 15:24:16.622: E/AndroidRuntime(675): at roman10.tutorial.calendarops.Main.getCalendars(Main.java:127) 12-21 15:24:16.622: E/AndroidRuntime(675): at roman10.tutorial.calendarops.Main.onCreate(Main.java:50) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Activity.performCreate(Activity.java:4465) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919) 12-21 15:24:16.622: E/AndroidRuntime(675): ... 11 more

2 个答案:

答案 0 :(得分:0)

这是:

  

android.database.sqlite.SQLiteException:没有这样的列:displayName:   ,同时编译:SELECT _id,displayName FROM Calendars

“日历”表中没有名称为“displayName”的列。

答案 1 :(得分:0)

由于您使用的是ICS(SDK 14),因此他们改变了处理Calanders的方式并制作了公共API。见http://android-developers.blogspot.com/2011/10/ics-and-non-public-apis.html