|
/

微信分享文本与链接分享成功,图片时出现错误(本地)

T*一梦
发布于 3 年前
7773来自广东省
社会化分享 U-Share
移动统计 U-App
功能使用

出现的错误:我参考了demo与示例都没有问题,应该是其他是原因

E/UMLog_Social: ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/UMLog_Social: │ 错误信息如下:
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ 错误类型:UID 10268 does not have permission to content://com.tencent.sample2.fileprovider/umeng_cache/6c309a7611ce431d453e2e023aa28dc5.jpg [user 0]
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.os.Parcel.createException(Parcel.java:2091)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.os.Parcel.readException(Parcel.java:2059)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.os.Parcel.readException(Parcel.java:2007)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.app.IActivityManager$Stub$Proxy.grantUriPermission(IActivityManager.java:5926)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.app.ContextImpl.grantUriPermission(ContextImpl.java:2063)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at android.content.ContextWrapper.grantUriPermission(ContextWrapper.java:805)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.media.WeiXinShareContent.getFileUri(WeiXinShareContent.java:238)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.media.WeiXinShareContent.buildImageParamsWithFileProvider(WeiXinShareContent.java:217)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.media.WeiXinShareContent.getWxMediaMessage(WeiXinShareContent.java:44)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.handler.UMWXHandler.shareTo(UMWXHandler.java:757)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.handler.UMWXHandler.share(UMWXHandler.java:619)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.b.a.a(SocialRouter.java:790)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.a$4.a(UMShareImpl.java:158)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.a$4.doInBackground(UMShareImpl.java:152)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at com.umeng.socialize.common.QueuedWork$UMAsyncTask$1.run(QueuedWork.java:133)
E/UMLog_Social: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
E/UMLog_Social: │ at java.lang.Thread.run(Thread.java:929)
E/UMLog_Social: └────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/UMLog_Social: body is null

我的代码,使用微信的,进行调用可以正常分享,但使用友盟的出现错误

body is null :似乎是我少传入了什么

//微信的
try {
Bitmap bitmap = SavePicUtils2.createBitmapFromView(cl_container);
WxLogin.wxShareImage(SendMessageToWX.Req.WXSceneSession, bitmap);
} catch (Exception e) {
ToastUtils.showLong("分享图片错误");
}

//友盟
UMImage imageurl = new UMImage(mActivity,R.drawable.ic_share_img);
imageurl.setThumb(new UMImage(mActivity, R.drawable.ic_online));
new ShareAction(mActivity).withMedia(imageurl )
.setPlatform(ShareHelp.wx_circle)
.setCallback(new WxShareHelp()).share();

简单继承 ,什么都没有
public class WxShareHelp implements UMShareListener {...

分享的是好友
public static SHARE_MEDIA wx_contact = SHARE_MEDIA.WEIXIN.toSnsPlatform().mPlatform; //微信好友
7个回答
 
3 年前
来自广东省

最终没有用友盟解决这个问题,看看微信的,调用微信api完成

贴下代码,有时间了在研究研究,毕竟使用起来方便很多

public class WxLogin {
public static final String APP_ID = ThirdPartyKey.wx_APP_ID;


public static final String wechat_app_secret_2 = ThirdPartyKey.wx_secret;
public static final String SCOPE = "snsapi_userinfo"; // 只能填 snsapi_userinfo req.scope
public static final String STATE = "wechat_sdk_demo_test"; //req.state


public static IWXAPI api;
public static Context mContext;
public static IWXAPI msgApi;

/**
* 反注册微信app 妈的管他也没有用,防止app推到后台后,他在后面搞事,导致上架审核不通过
*/
public static void unRegisterWxApp(){
if (msgApi!=null){
msgApi.unregisterApp();
}
}
public static boolean initWxSDK(Context context){
return WxLogin.initWx(context);
}

/**
* 急的初始化
*
* @param context
*/
public static boolean initWx(Context context) {
mContext = context;
api = WXAPIFactory.createWXAPI(context, APP_ID, true);
api.registerApp(APP_ID);

msgApi = WXAPIFactory.createWXAPI(context, null);
// 将该app注册到微信
msgApi.registerApp(APP_ID);
return true;
}

public static void longWx(String type) {
if (mContext == null) {
initWxSDK(BaseApplication.getInstance());
Log.e("TAG", "请做初始化动作,请调用 initWx(context)方法");
longWx(type);
return;
}
if (!api.isWXAppInstalled()) {
cn.wy69.base.utils.toast.ToastUtils.show("请先安装微信");
return;
}
final SendAuth.Req req = new SendAuth.Req();
req.scope = SCOPE;
// req.state = STATE;
req.state = type;
api.sendReq(req);

}

/**
* 微信分享 单独的图片
*
* @param scene
* @param bmp
*/
public static void wxShareImage(int scene, Bitmap bmp) throws IOException {
if (mContext == null) {
initWxSDK(BaseApplication.getInstance());
Toaster.show("资源准备成功,请重试");
Log.e("TAG", "请做初始化动作,请调用 initWx(context)方法");
wxShareImage(scene,bmp);
return;
}
if (!api.isWXAppInstalled()) {
cn.wy69.base.utils.toast.ToastUtils.show("请先安装微信");
return;
}

//初始化 WXImageObject 和 WXMediaMessage 对象
WXImageObject imgObj = new WXImageObject(bmp);
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;

//设置缩略图
Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 200, 200, true);
bmp.recycle();
msg.thumbData = bmpToByte(thumbBmp , true);

//构造一个Req
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = IntentEnumHelp.wxShareImg.getRemark();
req.message = msg;
req.scene = scene;
//调用api接口,发送数据到微信
api.sendReq(req);
}

/**
* 微信分享 分享到回话
*
* @param title 标题
* @param describe 描述
* @param url 注册地址 <Li>{@link IntentEnumHelp#register}</Li>
* @param bmp
* @param scene 分享到对话: SendMessageToWX.Req.WXSceneSession 分享到朋友圈: SendMessageToWX.Req.WXSceneTimeline ; 分享到收藏: SendMessageToWX.Req.WXSceneFavorite
* @throws IOException
*/
public static void wxShareUrl(String title, String describe, String url,int scene, Bitmap bmp) throws IOException {
if (mContext == null) {
initWxSDK(BaseApplication.getInstance());
Toaster.show("资源准备成功,请重试");
Log.e("TAG", "请做初始化动作,请调用 initWx(context)方法");
return;
}
if (!api.isWXAppInstalled()) {
cn.wy69.base.utils.toast.ToastUtils.show("请先安装微信");
return;
}

//初始化一个WXWebpageObject,填写url
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = url;

//用 WXWebpageObject 对象初始化一个 WXMediaMessage 对象
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = title;
msg.description = describe;

Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 400, 400, true);
bmp.recycle();
msg.thumbData = bmpToByte(thumbBmp , true);

SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = IntentEnumHelp.wxShareUrl.getRemark();
req.message = msg;
req.scene = scene;
//调用api接口,发送数据到微信
api.sendReq(req);
}


/**
* 分享一个链接
* @param scene 分享到对话: SendMessageToWX.Req.WXSceneSession 分享到朋友圈: SendMessageToWX.Req.WXSceneTimeline ; 分享到收藏: SendMessageToWX.Req.WXSceneFavorite
*/
public static void wxShareLink(String needShareLink,int scene){
if (mContext == null) {
initWxSDK(BaseApplication.getInstance());
Toaster.show("资源准备成功,请重试");
Log.e("TAG", "请做初始化动作,请调用 initWx(context)方法");
return;
}
if (!api.isWXAppInstalled()) {
cn.wy69.base.utils.toast.ToastUtils.show("请先安装微信");
return;
}

//初始化一个 WXTextObject 对象,填写分享的文本内容
WXTextObject textObj = new WXTextObject();
textObj.text = needShareLink;

//用 WXTextObject 对象初始化一个 WXMediaMessage 对象
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.description = needShareLink;

SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction =IntentEnumHelp.wxShareUrl.getRemark();
req.message = msg;
req.scene =scene;
//调用api接口,发送数据到微信
api.sendReq(req);
}

/**
* bitmap 转二进制
*
* @param bmp
* @param needRecycle
* @return
* @throws IOException
*/
private static byte[] bmpToByte(Bitmap bmp, boolean needRecycle) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] var4;
try {
bmp.compress(Bitmap.CompressFormat.PNG, 100, (OutputStream) output);
// if (needRecycle) {
// bmp.recycle();
// }

var4 = output.toByteArray();
} catch (Exception var8) {
var8.printStackTrace();
var4 = (byte[]) null;
} finally {
output.close();
}

return var4;
}

}
 
3 年前
来自浙江省

你好,分享的图片有超过限制吗

Loading ...
登录社区,分享你的经验