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

The new traffic code for Xiaohongshu promotion in 2022

Hot articles are the floodgates that open the tra...

How to name your website? How to name a Google website?

The name and domain name of the website cannot be...

Save your life! What should I do if I get frostbite in Harbin?

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

Live streaming + marketing, far more than just Wei Ya and Li Jiaqi

"At link No. 39, (everyone) remember to leav...

User growth activity matrix for online education

Online education has developed rapidly in 2020 an...

Rare! The explosive "blue tears" shocked the screen! What are "blue tears"?

Experts in this article: Sun Xueqiong, Master'...

How much does a generator cost? How much does a household generator cost?

The prices of units of different brands and confi...

Keep Product Analysis Report

As people pay more and more attention to health a...

E-commerce platforms create their own private domain traffic?

Private domain traffic is not a new term, nor did...