记录关于微信小程序分享问题

喜夏-厌秋 提交于 2019-12-04 21:57:37

1.分享有时成功 有时失败

具体失败样式为: 跳转至微信  选择完好友  显示已发送(显示1秒左右消失) 但好友并未收到此条分享

解决方法:

share2Wechat方法 我将所有分享到微信的类型都写进去了   

SendMessageToWX.Req req = new SendMessageToWX.Req();

req为分享到微信方法内的全局变量

在type = 小程序里 重新new  Req对象  解决此问题

2.分享小程序的图片 一直都为上次分享图片

eg.   应分享图片顺序依次为  A B  C   实际效果为   空  A   B

错误代码: 
private void errorCode(){
if (!TextUtils.isEmpty(shareInfo.picUrl)) {
Glide.with(context).load(shareInfo.picUrl).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
            shareBitmap = bitmap;
        }
    });
} else {
    shareBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.share_default_icon);
}
 share(shareInfo);
}

修改后:

private void Code(){
if (!TextUtils.isEmpty(shareInfo.picUrl)) {
 Glide.with(context).load(shareInfo.picUrl).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
            shareBitmap = bitmap;
            share(shareInfo);
        }
    });
} else {
    shareBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.share_default_icon);
    share(shareInfo);
}
}

因为图片为异步加载,图片还未加载成功,就直接执行share方法。  将share方法放至图片加载完成。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!