I am Using LinkedIn-j
API for LinkedIn Integration.
I am able to post Status Update.
I want to Show User Profile in WebView in Android for That I am getting User Public URL using below code.
person.getSiteStandardProfileRequest().getUrl();
which returning something like this http://www.linkedin.com/profileviewProfile=&key=100652876&authToken=AWW7&authType=name&trk=api*a169149*s177398*
If I am going to open this url in WebView then its Redirecting to LinkedIn Login page and after filling Credential I can see user Profile.
I want to open User Profile without entering Credential,Again
I also tried by appending the
URL&accesstoken="tokenIdReturned by Application";
But still I am not able to open the User Profile directly. What I am missing?
I had the same Requirement and i have done it with doing two things.
Firstly I have used My own WebView to load different URL to authenticate and to show profiles.I have made my WebView
as public static
instead using the default browser I have redirect the calls to my own WebView in my Activity.
Second I have set webview.getSettings().setAppCacheEnabled(true);
so now it doesn't ask for login again while viewing the profile.
I have declared my Activity as singleInstace
in Manifest.xml file.
UPDATE:
The way I used the WebView in My Activity.
public static WebView WV = null;
String uri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv);
if (WV == null) {
WV = (WebView) findViewById(R.id.webView1);
WV.getSettings().setJavaScriptEnabled(true);
WV.getSettings().setAppCacheEnabled(true); // the important change
WV.getSettings().setSupportZoom(true);
WV.getSettings().setBuiltInZoomControls(true);
}
final SharedPreferences pref = getSharedPreferences(OAUTH_PREF,
MODE_PRIVATE);
final String token = pref.getString(PREF_TOKEN, null);
final String tokenSecret = pref.getString(PREF_TOKENSECRET, null);
if (token == null || tokenSecret == null) {
startAutheniticate();
} else {
showCurrentUser(new LinkedInAccessToken(token, tokenSecret));
}
}
void startAutheniticate() {
final LinkedInRequestToken liToken = oAuthService
.getOAuthRequestToken(OAUTH_CALLBACK_URL);
uri = liToken.getAuthorizationUrl();
getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit()
.putString(PREF_REQTOKENSECRET, liToken.getTokenSecret())
.commit();
WV.loadUrl(uri);
}
void showCurrentUser(final LinkedInAccessToken accessToken) {
// code to get Profile object using Linkedin-J API
//which is already available on the API site as Example
WV.loadUrl(profile.getSiteStandardProfileRequest().getUrl());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With