我想在android中开发一个应用程序,我希望通过我的应用程序在日历中添加事件,以便从我的应用程序中查看它们,我该怎么做,任何教程或建议都会有所帮助
logcat文件是
06-24 10:09:17.056: ERROR/ActivityThread(610): Failed to find provider info for calendar
06-24 10:09:17.076: DEBUG/AndroidRuntime(610): Shutting down VM
06-24 10:09:17.076: WARN/dalvikvm(610): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): FATAL EXCEPTION: main
06-24 10:09:17.107: ERROR/AndroidRuntime(610): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.jimblackler.readcalendar/net.jimblackler.readcalendar.MainActivity}: java.lang.NullPointerException
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.os.Looper.loop(Looper.java:123)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread.main(ActivityThread.java:3647)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at dalvik.system.NativeStart.main(Native Method)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): Caused by: java.lang.NullPointerException
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at net.jimblackler.readcalendar.Example.readCalendar(Example.java:30)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at net.jimblackler.readcalendar.MainActivity.onCreate(MainActivity.java:13)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
06-24 10:09:17.107: ERROR/AndroidRuntime(610): ... 11 more
06-24 10:09:17.137: WARN/ActivityManager(68): Force finishing activity net.jimblackler.readcalendar/.MainActivity
06-24 10:09:18.486: WARN/ActivityManager(68): Activity pause timeout for HistoryRecord{406c0978 net.jimblackler.readcalendar/.MainActivity}
06-24 10:09:19.477: INFO/ActivityManager(68): Process com.google.android.apps.maps:FriendService (pid 589) has died.
06-24 10:09:20.736: WARN/InputManagerService(68): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40736c08
06-24 10:09:21.236: DEBUG/dalvikvm(68): GC_CONCURRENT freed 947K, 44% free 4739K/8327K, external 1426K/1936K, paused 32ms+43ms
06-24 10:09:21.275: INFO/Process(610): Sending signal. PID: 610 SIG: 9
06-24 10:09:21.287: INFO/dalvikvm(446): Wrote stack traces to '/data/anr/traces.txt'
06-24 10:09:21.327: INFO/ActivityManager(68): Process net.jimblackler.readcalendar (pid 610) has died.
答案 0 :(得分:1)
由于Android日历通常与Google日历相关联,为什么不使用Google Calendar API?看看这里:
http://code.google.com/intl/de-DE/apis/calendar/
您可以使用CalDAV协议代替Google API,这样可以在以后更轻松地切换到其他日历后端。
答案 1 :(得分:1)
试试这段代码
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent,0);