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 do advertisers choose “KOL” to promote their products?

Today, the self-media industry is developing at a...

The blender is too cruel! The Apple Watch instantly turned into dregs

A few days ago, we gave the Apple Watch a scratch...

How to use Tik Tok app? What is the delivery method?

When opening a store on Douyin, merchants also ne...

What is Geely’s plan behind its intensive deployment of new energy vehicles?

As cars are becoming more common in every househo...

Online promotion channels and methods

Here I will organize for you some free channels f...

How to outsource the development of security alarm mini program?

It can be seen from the current various "gat...