[Android] using Sina Weibo SDK for SSO Login

Source: Internet
Author: User

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 );

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.