ShareSDK能够调用getPlatform接口设置要分享的平台,上面是分享示例:

微信分享示例(好友、朋友圈、珍藏)

微信分享文本

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_TEXT);shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");platform.share(shareParams);

微信分享图片

留神: imageUrl(”网络图片链接”)、imagePath(“/sdcard/abc.jpg”)、imageData(bitmap)是三选一,同时Android11及之后的版本,微信分享图片不反对用imageData(bitmap)接口设置参数;

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_IMAGE);//分享网络图片shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")//分享本地图片//shareParams.setImagePath("本地图片的门路");//分享bitmap图片//shareParams.setImageData(bitmap);platform.share(shareParams);

微信分享音乐

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_MUSIC);shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")shareParams.setMusicUrl( "http://music.baidu.com/song/546920050?pst=sug"  );shareParams.setUrl("http://music.baidu.com/song/546920050?pst=su");platform.share(shareParams);

微信分享视频

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_VIDEO);shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")shareParams.setUrl("http://f1.webshare.mob.com/dvideo/demovideos.mp4");platform.share(shareParams);

微信分享网页

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_WEBPAGE);shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")shareParams.setUrl("https://www.mob.com/");platform.share(shareParams);

微信分享文件

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_FILE);shareParams.setTitle("测试分享的题目");shareParams.setFilePath("/storage/emulated/0/Android/data/cn.sharesdk.demo/files/text.txt");//文件本地门路platform.share(shareParams);

微信分享小程序

留神:只有微信好友反对分享小程序

Platform platform = ShareSDK.getPlatform(Wechat.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();//分享卡片模式小程序shareParams.setShareType(Platform.SHARE_WXMINIPROGRAM);//间接关上微信小程序//shareParams.setShareType(Platform.OPEN_WXMINIPROGRAM);shareParams.setText("测试文本");shareParams.setTitle("测试分享的题目");shareParams.setUrl("http://sharesdk.cn");shareParams.setImageUrl("https://hmls.hfbank.com.cn/hfapp-api/9.png");//小程序状态:0-正式,1-开发,2-体验shareParams.setWxMiniProgramType(0);  //微信小程序多选,默认只能分享一个微信好友,设置false后能够分享多个shareParams.setWxWithShareTicket(false);//分享的小程序页面门路,如不须要指定,请填主页门路(必填)shareParams.setWxPath("pages/index/index");shareParams.setWxUserName("gh_52568203455c");platform.share(shareParams);

新浪微博分享示例

新浪微博分享文字

Platform platform = ShareSDK.getPlatform(SinaWeibo.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");platform.share(shareParams);

新浪微博分享图文

留神: imageUrl(”网络图片链接”)、imagePath(“/sdcard/abc.jpg”)、imageData(bitmap)是三选一

Platform platform = ShareSDK.getPlatform(SinaWeibo.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");//分享网络图片shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")//分享本地图片//shareParams.setImagePath("本地图片的门路");//分享bitmap图片//shareParams.setImageData(bitmap);platform.share(shareParams);

新浪微博分享本地视频

Platform platform = ShareSDK.getPlatform(SinaWeibo.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");//视频文件本地门路shareParams.setFilePath("/sdcard/video.MP4");platform.share(shareParams);

QQ分享示例

QQ分享图片

留神:imageUrl(”网络图片链接”)、imagePath(“/sdcard/abc.jpg”)是二选一,同时QQ不反对分享bitmap图片

Platform platform = ShareSDK.getPlatform(QQ.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();//分享网络图片shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")//分享本地图片//shareParams.setImagePath("本地图片的门路");platform.share(shareParams);

QQ分享网页

Platform platform = ShareSDK.getPlatform(QQ.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")//网页链接shareParams.setTitleUrl("https://www.mob.com/");platform.share(shareParams);

QQ分享音频

Platform platform = ShareSDK.getPlatform(QQ.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setTitle("测试分享的题目");shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg")shareParams.setTitleUrl("https://www.mob.com/");//网页链接shareParams.setMusicUrl( "http://music.baidu.com/song/546920050?pst=sug"  );//音乐链接platform.share(shareParams);

QQ分享小程序

Platform platform = ShareSDK.getPlatform(QQ.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("QQ小程序");shareParams.setTitle("QQ互联");shareParams.setTitleUrl("http://www.qq.com/");shareParams.setImageUrl("http://www.3wyu.com/wpcontent/uploads/6e0eaf15gy1fvr5tnm2dfj20f108gtad.jpg");shareParams.setShareType(Platform.QQ_MINI_PROGRAM);//分享小程序appidshareParams.setQQMiniProgramAppid("1109762672"); //分享的小程序页面门路,如不须要指定,请填主页门路(必填)shareParams.setQQMiniProgramPath("pages/index/index");//3示意正式版,1示意体验版(可选)//shareParams.setQQMiniProgramType("");platform.share(shareParams);

QQ空间分享示例

留神:必须须要QQ客户端才能够分享, site是分享此内容的网站名称,仅在QQ空间应用;siteUrl是分享此内容的网站地址,仅在QQ空间应用;

QQ空间分享视频

Platform platform = ShareSDK.getPlatform(QZone.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_VIDEO);//视频文件本地门路shareParams.setFilePath("/sdcard/video.MP4");platform.share(shareParams);

QQ空间分享文本

Platform platform = ShareSDK.getPlatform(QZone.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setTitle("测试分享的题目");//网页链接shareParams.setTitleUrl("https://www.mob.com/");shareParams.setText("测试文本");shareParams.setSite("测试文本");shareParams.setSiteUrl("https://www.mob.com/");platform.share(shareParams);

QQ空间分享说说

Platform platform = ShareSDK.getPlatform(QZone.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg");shareParams.setSite("测试文本");shareParams.setSiteUrl("https://www.mob.com/");platform.share(shareParams);

QQ空间分享图文

Platform platform = ShareSDK.getPlatform(QZone.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setTitle("测试分享的题目");shareParams.setTitleUrl("https://www.mob.com/");shareParams.setText("测试文本");//本地图片门路shareParams.setImagePath("/storage/emulated/0/DCIM/Camera/IMG_20191001_113538.jpg");shareParams.setSite("测试文本");shareParams.setSiteUrl("https://www.mob.com/");platform.share(shareParams);

Facebook分享示例

Facebook分享网页

Platform platform = ShareSDK.getPlatform(Facebook.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setQuote("测试web引文分享");shareParams.setUrl("https://www.mob.com/");platform.share(shareParams);

Facebook分享图片

Platform platform = ShareSDK.getPlatform(Facebook.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setHashtag("测试话题分享");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg");platform.share(shareParams);

Facebook分享视频

Platform platform = ShareSDK.getPlatform(Facebook.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();//视频文件本地门路shareParams.setFilePath("/sdcard/video.MP4");platform.share(shareParams);

Facebook分享多图

Platform platform = ShareSDK.getPlatform(Facebook.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();//图片数组shareParams.setImageArray(AVATARS);platform.share(shareParams);

Twitter分享示例

Twitter分享文本

Platform platform = ShareSDK.getPlatform(Twitter.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");platform.share(shareParams);

Twitter分享图文

Platform platform = ShareSDK.getPlatform(Twitter.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg");platform.share(shareParams);

Twitter分享视频

Platform platform = ShareSDK.getPlatform(Twitter.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_VIDEO);//视频文件本地门路shareParams.setFilePath("/sdcard/video.MP4");platform.share(shareParams);

Instagram分享示例

Instagram分享图片

Platform platform = ShareSDK.getPlatform(Twitter.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();//文本不显示shareParams.setText("测试文本");shareParams.setImageUrl("https://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg");platform.share(shareParams);

Instagram分享图片

Platform platform = ShareSDK.getPlatform(Twitter.NAME);Platform.ShareParams shareParams = new Platform.ShareParams();shareParams.setShareType(Platform.SHARE_VIDEO);//文本不显示shareParams.setText("测试文本");//视频文件本地门路shareParams.setFilePath("/sdcard/video.MP4");platform.share(shareParams);