我正在使用LinkedIn-jAPI进行LinkedIn集成.
我可以发布状态更新.
我想在Android 中的WebView中显示用户配置文件,因为我使用下面的代码获取用户公共URL.
person.getSiteStandardProfileRequest().getUrl();
Run Code Online (Sandbox Code Playgroud)
返回这样的东西 http://www.linkedin.com/profileviewProfile=&key=100652876&authToken=AWW7&authType=name&trk=api*a169149*s177398*
如果我要在WebView中打开此URL,然后将其重定向到LinkedIn登录页面,在填写凭据后,我可以看到用户个人资料.
我想打开用户配置文件而不输入凭据,再次
我还尝试通过追加
URL&accesstoken="tokenIdReturned by Application";
Run Code Online (Sandbox Code Playgroud)
但我仍然无法直接打开用户个人资料.我错过了什么?
我有同样的要求,我做了两件事.
首先 我用我自己的WebView加载不同的URL来验证和展示profiles.I我做出WebView的public static ,而不是使用默认的浏览器我重定向到我的活动我自己的WebView调用.
其次我已经设置webview.getSettings().setAppCacheEnabled(true);好了,现在它不会在查看配置文件时再次请求登录.
我singleInstace在Manifest.xml文件中声明了我的Activity .
更新:
我在My Activity中使用WebView的方式.
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());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1401 次 |
| 最近记录: |