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

How should brands measure the effectiveness of advertising on TikTok?

Short videos have become popular, and a question ...

Mantou New Media Operation Video Course

Course Description A millionaire trader will teac...

Huawei Honor, Meizu Blue, why do mobile phone brands love to separate?

Recently, iPhone 8/8 Plus, iPhone X, Huawei Mate ...

Notice! Douyin, Baidu, and Toutiao's future marketing guidelines revealed~

Looking at the market, from the initial portal er...

Major adjustment: Apple will allow one-click rating and reply to user reviews

At the end of January, Apple announced a major ne...

9 examples of obtaining seed users

I often joke with my friends: Young people, don’t...

For nucleic acid testing, you must read these 10 points!

◎ Dai Xiaopei, a reporter from Science and Techno...