Android source code download: QQ third-party login demo

Android source code download: QQ third-party login demo

Functional classification: Other

Supported platforms: Android

Operating environment: Eclipse

Development language: Java

Development tool: Eclipse

Source code size: 1.31MB

Source code download address: http://down..com/data/1976923

Source code introduction

I have been using third-party login recently. There are too many classes in the official demo provided by QQ for login. Here I upload a small demo with only 2 classes, which can authorize QQ for third-party login.

Source code running screenshot

Authorization login interface

Authorization successful return value

Main Page

Source code snippet

  1. Handler mHandler = new Handler() {
  2.   
  3. @Override  
  4. public   void handleMessage(Message msg) {
  5. if (msg.what == 0 ) {
  6. JSONObject response = (JSONObject) msg.obj;
  7. if (response.has( "nickname" )) {
  8. try {
  9. mUserInfo.setVisibility(android.view.View.VISIBLE);
  10. mUserInfo.setText(response.getString( "nickname" ));
  11. } catch (JSONException e) {
  12. // TODO Auto-generated catch block  
  13. e.printStackTrace();
  14. }
  15. }
  16. } else   if (msg.what == 1 ) {
  17. Bitmap bitmap = (Bitmap) msg.obj;
  18. mUserLogo.setImageBitmap(bitmap);
  19. mUserLogo.setVisibility(android.view.View.VISIBLE);
  20. }
  21. }
  22.   
  23. };
  24.   
  25. private   void onClickLogin() {
  26. if (!mQQAuth.isSessionValid()) {
  27. IUiListener listener = new BaseUiListener() {
  28. @Override  
  29. protected   void doComplete(JSONObject values) {
  30. updateUserInfo();
  31. updateLoginButton();
  32. }
  33. };
  34. mQQAuth.login( this , "all" , listener);
  35. // mTencent.loginWithOEM(this, "all",  
  36. // listener,"10000144","10000144","xxxx");  
  37. mTencent.login( this , "all" , listener);
  38. } else {
  39. mQQAuth.logout( this );
  40. updateUserInfo();
  41. updateLoginButton();
  42. }
  43. }
  44.   
  45. public   static   boolean ready(Context context) {
  46. if (mQQAuth == null ) {
  47. return   false ;
  48. }
  49. boolean ready = mQQAuth.isSessionValid()
  50. && mQQAuth.getQQToken().getOpenId() != null ;
  51. if (!ready)
  52. Toast.makeText(context, "login and get openId first, please!" ,
  53. Toast.LENGTH_SHORT).show();
  54. return ready;
  55. }
  56.   
  57. private   class BaseUiListener implements IUiListener {
  58.   
  59. @Override  
  60. public   void onComplete(Object response) {
  61. Util.showResultDialog( MainActivity.this , response.toString(),
  62. "Login successful" );
  63. doComplete((JSONObject) response);
  64. }
  65.   
  66. protected   void doComplete(JSONObject values) {
  67.   
  68. }
  69.   
  70. @Override  
  71. public   void onError(UiError e) {
  72. Util.toastMessage(MainActivity. this , "onError: " + e.errorDetail);
  73. Util.dismissDialog();
  74. }
  75.   
  76. @Override  
  77. public   void onCancel() {
  78. Util.toastMessage(MainActivity. this , "onCancel: " );
  79. Util.dismissDialog();
  80. }
  81. }

Source code download address: http://down..com/data/1976923

<<:  MDSA Mobile Developer Service Alliance offline open class 01 summary topic and PPT download

>>:  Android source code download: My Gesture Lock

Recommend

On the rise of Chinese companies' overseas acquisitions: a blessing or a curse?

UBS analyzed the current rise of Chinese multinat...

Itching, itching, itching and peeling may also be cancer?

Review expert: Zhang Yuhong, chief physician of t...

Talking about iOS large-scale project development

[[147407]] The title is a bit scary, please don&#...

How to implement Baidu information flow delivery from 0 to 1?

Baidu information flow was developed after Baidu ...

Is the fetus a parasite of the mother? Let's make this clear today

Rumors Nowadays, more and more young people are &...

Advertising your own products is the correct way to promote your products!

When it comes to promotion , most people think of...

The secret to quickly increase followers on a public account!

The ideal of many Internet newcomers is how to re...

Baidu snapshot hijacking tutorial, sharing of real cases of Baidu snapshot hijacking!

Maybe some friends still don’t know what “Baidu s...