在设备和仿真器的Andr​​oid LinkedIn集成错误仿真器、错误、设备、Andr

2023-09-05 02:50:00 作者:追风

我试图整合LinkedIn用了这个问题的答案Posting从Android应用程序 LinkedIn消息  但在不工作的设备是这样给出的例子LITest显示我像下面

I am trying to integrated linkedIn using this question answer Posting LinkedIn message from Android application but this given example LITest in not working on Device is Shows me some Error like below

  12-19 19:36:30.489: ERROR/AndroidRuntime(11868): FATAL EXCEPTION: main
12-19 19:36:30.489: ERROR/AndroidRuntime(11868): java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.osadkowski.LITest/pl.osadkowski.LITest.LITestActivity}: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread.access$2300(ActivityThread.java:126)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.os.Looper.loop(Looper.java:123)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread.main(ActivityThread.java:4633)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at java.lang.reflect.Method.invokeNative(Native Method)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at java.lang.reflect.Method.invoke(Method.java:521)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at dalvik.system.NativeStart.main(Native Method)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868): Caused by: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:180)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at pl.osadkowski.LITest.LITestActivity.onCreate(LITestActivity.java:49)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     ... 11 more
12-19 19:36:30.489: ERROR/AndroidRuntime(11868): Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:172)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     ... 14 more
12-19 19:36:30.489: ERROR/AndroidRuntime(11868): Caused by: java.io.FileNotFoundException: https://api.linkedin.com/uas/oauth/requestToken
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:1162)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:253)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getContent(HttpURLConnectionResponseAdapter.java:18)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:228)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
12-19 19:36:30.489: ERROR/AndroidRuntime(11868):     ... 16 more

当我在模拟器中运行它会问我的应用程序的授权,我已经授予应用程序。 之后,我不会被重定向到应用程序。请参见下图。

When i run it on Emulator it will ask me for Authorization of app, i had grant the App. After the i will not be redirected to the app. Please see below image.

推荐答案

首先尝试清除cookies,您初始化LinkedIn相关的对象之前...使用下面code

First Try to clear cookies before you init LinkedIn related object... Use Below Code

CookieSyncManager.createInstance(this);

CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();   

如果它工作还是不请更新我....

Please update me if it works or not....