如何在Android中以编程方式从谷歌联系人获取联系人

时间:2012-03-20 04:48:38

标签: android

我正在使用contacservice类,我设置了我的Gmail帐户的用户凭据 我想从谷歌联系人那里得到我的代码的联系方式如下

ContactService myservice=new ContactService("ex-app-1.0");

  myservice.setUserCredentials("username","password");

  URL url=new URL("https://www.google.com/m8/feeds/contacts/xxx@gmail.com/full");

ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);

但我在logcat

中遇到了这样的异常
03-16 12:24:49.217: E/AndroidRuntime(1013): FATAL EXCEPTION: main

03-16 12:24:49.217: E/AndroidRuntime(1013): java.lang.RuntimeException: Unable to start activity

ComponentInfo{c.b.p/c.b.p.ContactsBackupActivity}: java.lang.NullPointerException

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.os.Looper.loop(Looper.java:123)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-16 12:24:49.217: E/AndroidRuntime(1013):     at java.lang.reflect.Method.invokeNative(Native Method)
03-16 12:24:49.217: E/AndroidRuntime(1013):     at java.lang.reflect.Method.invoke(Method.java:521)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at dalvik.system.NativeStart.main(Native Method)

03-16 12:24:49.217: E/AndroidRuntime(1013): Caused by: java.lang.NullPointerException
03-16 12:24:49.217: E/AndroidRuntime(1013):     at c.b.p.ContactsBackupActivity.onCreate(ContactsBackupActivity.java:128)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

03-16 12:24:49.217: E/AndroidRuntime(1013):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

03-16 12:24:49.217: E/AndroidRuntime(1013):     ... 11 more
03-16 12:29:49.329: I/Process(1013): Sending signal. PID: 1013 SIG: 9

0 个答案:

没有答案