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

Introduction to Douyin brand advertising and advertising resources

Preface Tik Tok is now the largest APP in China, ...

In the era of intelligent computing, a Chinese answer

This year, as AI big models have been rapidly rec...

The suffering of Internet TV companies has just begun

In the past few years, those Internet TV brands t...

It's a fake volcano that spits mud!

Mud volcano is a unique geological phenomenon. It...

Baiguoyuan-Private Domain Methodology!

What constitutes an “ideal” private domain? How m...

Can ASO be performed in the Android Market? Do you know how to do it?

Many domestic channels are based on quantity, but...

The first lesson for parents to teach their children about financial literacy

Resources for parents’ first parent-child financi...