"Framework" SHARESDK sharing and third-party login

Source: Internet
Author: User

/*** 1. Download the SDK and unzip * 2. Double-click the Quickintegrater.jar file, select the platform to share, generate the sample folder, and merge the files in the sample folder into the project * 3. Add permissions to the manifest file * 4. Add callback activity in the manifest file * 5. Replace Appkey * 6. Add share code*/ Public classMainactivityextendsappcompatactivity {Privatefile file; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); SHARESDK.INITSDK ( This); File=NewFile (Environment.getexternalstoragepublicdirectory (environment.directory_downloads), "123.png"); }     Public voidShare (view view) {onekeyshare OKs=NewOnekeyshare (); //Turn off SSO licensingoks.disablessowhenauthorize ();//This method is not called when sharing notification icons and text 2.5.9 later versions//oks.setnotification (R.drawable.ic_launcher, getString (r.string.app_name)); //title, Evernote, email, information, Renren and QQ space useOks.settitle (getString (R.string.share)); //Titleurl is the title of the network link, only in Renren and QQ space useOks.settitleurl ("http://sharesdk.cn"); //Text is shared, and all platforms require this fieldOks.settext ("I am sharing text"); //ImagePath is the local path to the picture, and this parameter is supported on platforms other than Linked-inOks.setimagepath (File.getabsolutepath ()); //Oks.setimagepath ("/sdcard/test.jpg");//Make sure this picture exists under SDcard//URLs are only used in (including friends and friends circles)Oks.seturl ("http://sharesdk.cn"); //comment is my comment on this share, only used in Renren and QQ spaceOks.setcomment ("I am the test comment text"); //site is the name of the website that shares this content and is used only in QQ spaceOks.setsite (getString (r.string.app_name)); //SiteURL is the address of the website sharing this content, only in the QQ space useOks.setsiteurl ("http://sharesdk.cn");//start sharing GUIOks.show ( This); }     Public voidLogin (view view) {//Login//Authorize (new QQ (this));Platform Weibo =Sharesdk.getplatform (sinaweibo.name);//Weibo.setplatformactionlistener (palistener);weibo.authorize ();//Remove Authorization//Weibo.removeaccount (true);    }     Public voidauthorize (Platform Platform) {//determine if the user has authorized        if(Platform.isauthvalid ()) {//Get user nameString UserName =Platform.getdb (). GetUserName (); LOG.D ("GOOGLE_LENVE_FB", "Authorize:" +userName); } Else {            //directing users to sign inplatform.authorize (); }        //Monitor three-party login statusPlatform.setplatformactionlistener (NewPlatformactionlistener () {//callback This method when login is successful@Override Public voidOnComplete (Platform Platform,intI, hashmap<string, object>HashMap) {LOG.D ("GOOGLE_LENVE_FB", "OnComplete: Login Successful"); }            //callback This method when login fails@Override Public voidOnError (Platform Platform,intI, Throwable throwable) {} @Override Public voidOnCancel (Platform Platform,inti) {}}); }}

"Framework" SHARESDK sharing and third-party login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.