Android- League of Friends Sign in and share

### Foreword recent project once again need to be integrated with the tripartite Login Share Friends of the Union, not previously recorded before, so this time to write about ... ### Preparation 1. Registration League of Friends of account creation application, access key: application address http://www.umeng.com 2. for the corresponding platform (Tencent, micro-channel, Sina, etc.) apply for third-party account, access key and password ### integration steps because shareSDK shared with third parties to log an integrated manner similar (shared jar package), so I say together. ##### 1. Download shareSDK share of the SDK download address: https: //developer.umeng.com/sdk [] (https://img2018.cnblogs.com/blog/1312938/201909/1312938-20190907085917512-! 365962928.png) ##### 2. importing res open jar and development documentation and download the corresponding SDK and demo, to select the function you need when you download the SDK! [] (https://img2018.cnblogs.com/blog /1312938/201909/1312938-20190907085918284-725807555.png) downloaded files corresponding to the function as shown below:! [] (https://img2018.cnblogs.com/blog/1312938/201909/1312938-20190907085919354-1012739336 .png)! [] (https://img2018.cnblogs.com/blog/1312938/201909/1312938-20190907085919893-1747564218.png) into Android studio and add dependency ##### Android Manifest XML configuration sdk Activity in need - Sina `` ` `-` `` micro-letter ``` - QQ ``` `` `Add a privilege:` `` `` ##### Android6.0 adaptation rights adapted `` `if (Build.VERSION.SDK_INT> = 23) {String [] mPermissionList = new String [] {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission .ACCESS_FINE_LOCATION, Manifest.permission.CALL_PHONE, Manifest.permission.READ_LOGS, Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.SET_DEBUG_APP, Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.GET_ACCOUNTS, Manifest.permission.WRITE_APN_SETTINGS }; ActivityCompat.requestPermissions (this, mPermissionList, 123);} `` `wherein requestCode 123 is, according to this code is determined, the user whether to agree to the license. If there is no agreement, it may be dealt with accordingly callback: `` `@Override public void onRequestPermissionsResult (int requestCode, String permissions [], int [] grantResults) {}` `` ##### `` `@Override initialization settings public void onCreate () {super.onCreate (); UMConfigure.init (this, "5a12384aa40fa3551f0001d1", d497e70d4c3e4efeab1381476bac4c5e "); PlatformConfig.setPinterest (" 1439206 "); PlatformConfig.setKakao (" e4f60e065048eb031e235c806b31c70f "); PlatformConfig.setDing (" dingoalmlnohc0wggfedpk "); PlatformConfig.setVKontakte (" 5764965 "," 5My6SNliAaLxEm3Lyd9J "); PlatformConfig.setDropbox (" oz8v5apet3arcdy "," h7p2pjbzkkxt02a "); PlatformConfig.setYnote (" 9c82bf470cba7bd2f1819b0ee26f86c6ce670e9b ");` `` ##### signatures must apk after the keystore signature test, signature file if not, part of the platform of the authorization will be affected #. ## use a step ##### Share Share Friends of the Union divided into two forms: using Share Share panel, the user can call our method to open the share panel, click on the Share panel corresponding platform sharing is not used to share. Share panel, users can write their own share button, or trigger event, then call us to share methods, to share short, direct Share Share behavior is inserted in the user's own interface components, we write to share the panel is open a good interface component, root Click to open the event to share the code sharing panel as follows:. `` `New ShareAction (MainActivity.this) .setPlatform (SHARE_MEDIA.QQ) // Incoming platform .withText (" hello ") // share content. Sign in Sign in using contains two scenarios: get the user's authorization data interfaces, use the interface can get all the information returned by the tripartite platform (including name, gender, avatar, etc.) logged a third party platform currently supports include: China platform (micro-channel, Sina Weibo, QQ, watercress, everyone) foreign platforms (Facebook, Twitter, linkedIn, kakao, VKontakte, Dropbox) It is recommended to use the first direct manner, because in essence three parties need to pull enter final tripartite platform user data, from this point, and direct calls by back-end server requests SDK, security is the same as third-party login contains two usage scenarios: get the user information authorization interface, this interface can be obtained using the tripartite platform All information return (including name, gender, head, etc.) currently support third-party platforms, including login: domestic platform (micro-channel, Sina Weibo, QQ, watercress, everyone) foreign platforms (Facebook, Twitter, linkedIn, kakao, VKontakte , Dropbox) It is recommended to use the first direct party Style achieved because the three parties eventually need to log in to pull user information on the nature of the tripartite platform, from this point, and direct calls by back-end server requests SDK, security is the same as ##### to obtain the user data to obtain the user data you can use the following interfaces: `` `mShareAPI.getPlatformInfo (UserinfoActivity.this, SHARE_MEDIA.SINA, umAuthListener); data) {Toast.makeText (mContext, "success", Toast.LENGTH_LONG) .show ();} / ** * @desc authorization failed callback * @param platform platform name * @param action acts numbers, with developers * @param t is not the cause of the error * / @Override public void onError (SHARE_MEDIA platform, int action, Throwable t) {Toast.makeText (mContext, "failed:" + t.getMessage (), Toast.LENGTH_LONG) .show ( );} / ** * @desc authorized to cancel callback * @param platform platform No. name * @param action behavior, developers do not have access * / @Override public void onCancel (SHARE_MEDIA platform, int action) {Toast.makeText ( mContext, "canceled", Toast.LENGTH_LONG) .show ();}}; `` `after a successful login, third-party platform sends the user data back, all will return in the Map data. There are other features we can see the development of the document Friends of the Union address: https://developer.umeng.com/docs/66632/detail/66639 we can focus my micro-channel public number: "Qin Shuai child" a quality with the attitude of the public number! ! [Public number] (https://img2018.cnblogs.com/blog/1312938/201909/1312938-20190907085920242-1060721137.jpg)

Guess you like

Origin www.cnblogs.com/qinzishuai/p/11479161.html