Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get public profile url from LinkedIn in Android (BufferedInputStream is closed)

I am unable to get the public profile url and get or post from the LinkedIn api in Android. I'm using linkedin-j-android source. I'm able to get successful accesstoken but when calling this line from OnNewIntent.

Edited: I have internet permission in my app. So this will not be a problem.

Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));

 @Override
    protected void onNewIntent(Intent intent) {     

        String verifier = intent.getData().getQueryParameter("oauth_verifier");
        LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
        client = factory.createLinkedInApiClient(accessToken);      
        Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));
        Log.v("","PUBLIC_PROFILE_URL:" + profile.getPublicProfileUrl());
    }

the app crashes. Below is the log trace.

FATAL EXCEPTION: main
com.google.code.linkedinapi.client.LinkedInApiClientException: java.io.IOException: BufferedInputStream is closed
at com.google.code.linkedinapi.client.impl.LinkedInApiXppClient.unmarshallObject(LinkedInApiXppClient.java:167)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.readResponse(BaseLinkedInApiClient.java:3710)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3777)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3725)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.getProfileForCurrentUser(BaseLinkedInApiClient.java:1122)

Please help me. Thanks in advance.

like image 978
fargath Avatar asked Jan 18 '13 10:01

fargath


People also ask

How do I find my LinkedIn URL on Android?

Tap your profile photo > View Profile. Scroll down to the Contact section. Under the Your Profile section, locate your public profile URL.

How do I find my LinkedIn profile URL API?

You need to add r_basicprofile to the scope query param. Here you can see that you are able to fetch the vanityName property, then all you need to do is concatenate with https://www.linkedin.com/in/ to have the full profile URL as in "https://www.linkedin.com/in/ + vanityName"


1 Answers

is this code snippet working for you :

   Person profile = client.getProfileForCurrentUser();
   Log.v("","PUBLIC_PROFILE_URL:" + profile.getPublicProfileUrl());
like image 184
Nimish Choudhary Avatar answered Oct 18 '22 04:10

Nimish Choudhary