share sdk

1.这个是集成share sdk 分享的一些个人经验

2.下面的是控制微信,QQ等的点击事件

share sdk_第1张图片

3.下面的方法就是点击微信,QQ后跳转分享界面的,注释后,点击就不会跳转分享界面了.

share sdk_第2张图片

4.下面的这个是取消shareSDK分享界面消失时半透明动画

share sdk_第3张图片

5.这个是区分点击的是微信还是qq还是微博等的操作

share sdk_第4张图片

6.这个是控制分享成功或者是分享失败的监听.

oks.setCallback(new PlatformActionListener() {
            @Override
            public void onComplete(Platform platform, int i, HashMap hashMap) {
                Log.d("ShareLogin", "onComplete ---->  分享成功");
                platform.getName();
            }

            @Override
            public void onError(Platform platform, int i, Throwable throwable) {
                Log.d("ShareLogin", "onError ---->  失败" + throwable.getStackTrace());
                Log.d("ShareLogin", "onError ---->  失败" + throwable.getMessage());
                throwable.printStackTrace();


            }

            @Override
            public void onCancel(Platform platform, int i) {
                Log.d("ShareLogin", "onCancel ---->  分享取消");
            }
        });

// 启动分享GUI
        oks.show(this);

 

7.这个是具体的区分点击的QQ还是微信的分享

OnekeyShare oks = new OnekeyShare();
        /*oks.addHiddenPlatform(
QQ.NAME);
        oks.setImageData();
        oks.setSilent(true);*/
        oks.disableSSOWhenAuthorize();
        oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {
            @Override
            public void onShare(Platform platform, cn.sharesdk.framework.Platform.ShareParams paramsToShare) {
                if ("SinaWeibo".equals(platform.getName())) {
                    paramsToShare.setText("玩美夏日,护肤也要肆意玩酷!");
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                    /*paramsToShare.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());*/
                    /*paramsToShare.setUrl("
http://sharesdk.cn");*/
                }
                if ("Wechat".equals(platform.getName())) {
                    paramsToShare.setTitle("标题");
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦");
                    /*paramsToShare.setWxUserName("");
                    paramsToShare.setW*/
                    /*Bitmap imageData = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
                    paramsToShare.setImageData(imageData);*/
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                    paramsToShare.setUrl("
http://sharesdk.cn");
                    paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
                    Log.d("ShareSDK", paramsToShare.toMap().toString());
                    Toast.makeText(MainActivity.this, "点击微信分享啦", Toast.LENGTH_SHORT).show();
                }
                if ("WechatMoments".equals(platform.getName())) {
                    paramsToShare.setTitle("标题");
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦");
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                    paramsToShare.setUrl("
http://sharesdk.cn");
                    paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
                }
                if ("QQ".equals(platform.getName())) {
                    paramsToShare.setTitle("标题");
                    paramsToShare.setTitleUrl("
http://sharesdk.cn");
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦");
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                    Toast.makeText(MainActivity.this, "点击QQ分享啦", Toast.LENGTH_SHORT).show();
                }
                if ("Facebook".equals(platform.getName())) {
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦");
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                }
                if("Twitter".equals(platform.getName())){
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦");
                    paramsToShare.setImageUrl("
https://hmls.hfbank.com.cn/hfapp-api/9.png");
                    /*paramsToShare.setUrl("
http://sharesdk.cn");*/
                }
                if("ShortMessage".equals(platform.getName())){
                    paramsToShare.setText("我是共用的参数,这几个平台都有text参数要求,提取出来啦" + "
https://m.xiepinhui.com.cn/webnine/active_goodsinfo?goodsId=998&activeId=0&rebate=0");
                }
            }
        });

8.// 设置分享事件回调(注:回调放在不能保证在主线程调用,不可以在里面直接处理UI操作)

 

 

 

 

 

你可能感兴趣的:(Android)