zoukankan      html  css  js  c++  java
  • shareSDK集成步骤

    按下面目录结构吧sdk的目录文件拷贝到自己的工程中

    针对各个平台的分享格式,整理成了一个工具类,不同的平台分享的参数http://wiki.mob.com/不同平台分享内容的详细说明/

    package com.chuangyuan.qdocument.utils;
    
    import android.content.Context;
    import android.util.Log;
    
    import com.chuangyuan.qdocument.R;
    
    import cn.sharesdk.framework.Platform;
    import cn.sharesdk.framework.ShareSDK;
    import cn.sharesdk.onekeyshare.OnekeyShare;
    import cn.sharesdk.onekeyshare.ShareContentCustomizeCallback;
    
    /**
     * Created by Administrator on 2016/4/25 0025.
     */
    public class MobUtils {
    
        public static void showShare(Context context, final String path) {
            ShareSDK.initSDK(context);
            OnekeyShare oks = new OnekeyShare();
            //关闭sso授权
            oks.disableSSOWhenAuthorize();
    
    // 分享时Notification的图标和文字  2.5.9以后的版本不调用此方法
            //oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
            // title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间使用
           // oks.setTitle(context.getString(R.string.share));
            // titleUrl是标题的网络链接,仅在人人网和QQ空间使用
            oks.setTitleUrl("http://sharesdk.cn");
            // text是分享文本,所有平台都需要这个字段
            oks.setText("我是分享文本");
            // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
            //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
            // url仅在微信(包括好友和朋友圈)中使用
            oks.setUrl("http://sharesdk.cn");
            // comment是我对这条分享的评论,仅在人人网和QQ空间使用
            oks.setComment("我是测试评论文本");
            // site是分享此内容的网站名称,仅在QQ空间使用
            oks.setSite(context.getString(R.string.app_name));
            // siteUrl是分享此内容的网站地址,仅在QQ空间使用
            oks.setSiteUrl("http://sharesdk.cn");
    
    
    // 参考代码配置章节,设置分享参数
    //通过OneKeyShareCallback来修改不同平台分享的内容
            oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {
                @Override
                public void onShare(Platform platform, Platform.ShareParams paramsToShare) {
                    if("Email".equals(platform.getName())){//邮箱
                        paramsToShare.setAddress("liu_xingxing@create.com.cn");
                        paramsToShare.setText("分享到邮箱");
                        paramsToShare.setImagePath(path);
                    }else if("SinaWeibo".equals(platform.getName())){
                        paramsToShare.setText("分享到新浪微博");
                        paramsToShare.setImagePath(path);
                    }else if("TencentWeibo".equals(platform.getName())){//腾讯微博
                        paramsToShare.setText("分享到腾讯微博");
                        paramsToShare.setImagePath(path);
                    }else if("Facebook".equals(platform.getName())){//facebook
                        paramsToShare.setText("分享到facebook");
                        paramsToShare.setImagePath(path);
                    }else if("Twitter".equals(platform.getName())){//twitter
                        paramsToShare.setText("分享到twitter");
                        paramsToShare.setImagePath(path);
                    }else if("ShortMessage".equals(platform.getName())){//短信
                        paramsToShare.setText("分享到短信");
                        paramsToShare.setImagePath(path);
                    }else if("QQ".equals(platform.getName())){//qq
                        paramsToShare.setText("分享QQ");
                        paramsToShare.setImagePath(path);
                    }else if("YouDao".equals(platform.getName())){//有道云笔记
                        paramsToShare.setText("分享到有道云笔记");
                        paramsToShare.setImagePath(path);
                    }
    
                }
            });
    
    // 启动分享GUI
            oks.show(context);
        }
    }
  • 相关阅读:
    使用GDI+将24位真彩色图像转换为8位灰度图像
    Disable SIP automatic popup
    [转]"分析 EntityName 时出错"的解决方案
    PHP中文件读写操作
    VC6 combobox使用
    [转]WinCE下消息队列用法
    Java8 stream处理List,Map总结
    【工具】cephbluestoretool
    读的
    【osd | 运维】pg相关命令
  • 原文地址:https://www.cnblogs.com/epmouse/p/5430946.html
Copyright © 2011-2022 走看看