QQ好友分享时,当设置的分享contentType 为"image"时,分享失败 ShareContent 分享内容接口:
public class ShareContent implements Serializable {
<span class="hljs-comment">/* * 分享类型:"url" 为分享链接,"image" 为分享图片 */</span> <span class="hljs-keyword">private</span> <span class="hljs-built_in">String</span> contentType;
}
一、配置信息
1、AndroidManifest.xml添加FileProvider
2、res/xml/provider_paths.xml
<paths> <!--分享设置Fileprovider--> <external-path name="files_root" path="Android/data/com.mpaas.demo" /> <external-path name="external_files" path="." /> </paths>
二、分享代码添加setFileProviderAuthority //图片分享添加 setFileProviderAuthority private void shareToQQ() { service.initQQ("1104122330"); ShareContent content = linkImg (ShareType.SHARE_TYPE_QQ); //图片分享 content.setFileProviderAuthority("com.mpaas.demo.fileprovider"); service.setShareActionListener(mShareListener); service.silentShare(content, ShareType.SHARE_TYPE_QQ, "test"); }
/**
* 生成分享内容
*
* @return 分享内容
*/
private ShareContent linkImg (int shareType) { final ShareContent content = new ShareContent();
// 设置分享内容
content.setContent("mPaaS share content");
// 设置分享类型,分享链接请选择"url" content.setContentType("image");
// 设置分享标题