1. Brief Introduction
Now it is July, and the latest SDK is released in July. I have not updated it recently.
SDK download link: Release.
Last August SDK: http://download.csdn.net/detail/u011267546/5814259
2. Prepared content
Comsume Key and Redirect url. For details, see weibo_android_sdkin sdk.
3. manifest
Permission
<Uses-permission android: name = "android. permission. INTERNET"> </uses-permission>
<Uses-permission android: name = "android. permission. ACCESS_WIFI_STATE"> </uses-permission>
<Uses-permission android: name = "android. permission. WRITE_APN_SETTINGS"> </uses-permission>
<Uses-permission android: name = "android. permission. CHANGE_WIFI_STATE"> </uses-permission>
4. API
Logon authorization
Weibo mWeibo = Weibo O. getInstance (APP_KEY, REDIRECT_URL );
SsoHandler mSsoHandler = new SsoHandler (context, mWeibo); // context is the context of the Activity for login
WeiboAuthListener authListener = new WeiboAuthListener (){
@ Override
Public void onWeiboException (WeiboException arg0 ){
L. d (this, "onWeiboException ");
// TODO: process failed authorization
}
@ Override
Public void onError (WeiboDialogError arg0 ){
L. d (this, "onError ");
// TODO: process failed authorization
}
@ Override
Public void onComplete (Bundle values ){
L. d (this, "onComplete ");
String token = values. getString ("access_token ");
String expires_in = values. getString ("expires_in ");
// TODO: authorization is successful
}
@ Override
Public void onCancel (){
L. d (this, "onCancel ");
// Todo: handle authorization Cancellation
}
};
Call the code in the authorized activity. The request code is 32973.
@ Override
Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
Super. onactivityresult (requestcode, resultcode, data );
If (mssohandler! = NULL ){
Mssohandler. authorizecallback (requestcode, resultcode, data );
}
}