当前位置: 首页>>代码示例>>Java>>正文


Java WXMediaMessage.setThumbImage方法代码示例

本文整理汇总了Java中com.tencent.mm.sdk.modelmsg.WXMediaMessage.setThumbImage方法的典型用法代码示例。如果您正苦于以下问题:Java WXMediaMessage.setThumbImage方法的具体用法?Java WXMediaMessage.setThumbImage怎么用?Java WXMediaMessage.setThumbImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tencent.mm.sdk.modelmsg.WXMediaMessage的用法示例。


在下文中一共展示了WXMediaMessage.setThumbImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shareHypeLink

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
/**
 * 分享链接。在对话中,显示title,pic,description三个元素。在朋友圈中,显示title、pic两个元素。
 *
 * @param title      标题
 * @param text       朋友圈中不显示。
 * @param picPath    缩略图的本地路径
 * @param url        链接的地址
 * @param isTimeline 分享至微信聊天,还是朋友圈。true:分享至朋友圈;false:分享至微信聊天
 */
private void shareHypeLink(String title, String text, String picPath,
                           String url, int thumbNailSize, boolean isTimeline) {
    WXWebpageObject webPage = new WXWebpageObject();
    webPage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webPage);
    msg.title = title;
    msg.description = text;
    if (picPath != null) {
        Bitmap thumb = ShareWechatUtils.extractThumbNail(picPath,
                thumbNailSize, thumbNailSize, true);
        if (thumb != null) {
            Logger.e("Share:", "图片不为null");
            msg.setThumbImage(thumb);
        }
    }
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = ShareWechatUtils.buildTransaction("webpage");
    req.message = msg;
    req.scene = isTimeline ? SendMessageToWX.Req.WXSceneTimeline
            : SendMessageToWX.Req.WXSceneSession;
    mAPI.sendReq(req);
}
 
开发者ID:markzhai,项目名称:AndroidProjectFrom0,代码行数:32,代码来源:WeChatSharePlugin.java

示例2: buildWXMediaMessage

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
/**
 * 构建WXMediaMessage
 *
 * @param bitmap
 */
private WXMediaMessage buildWXMediaMessage(Bitmap bitmap) {
    WXMediaMessage wxMediaMessage = new WXMediaMessage();
    wxMediaMessage.title = data.getTitle();
    wxMediaMessage.description = data.getContent();
    if (TextUtils.isEmpty(data.getUrl())) {
        wxMediaMessage.mediaObject = new WXTextObject(data.getContent());
    } else {
        if (null != bitmap) {
            wxMediaMessage.setThumbImage(getWxShareBitmap(bitmap));
        } else {
            Bitmap defautlBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.share_default);
            if (null != defautlBitmap) {
                wxMediaMessage.setThumbImage(getWxShareBitmap(defautlBitmap));
            }
        }
        wxMediaMessage.mediaObject = new WXWebpageObject(data.getUrl());
    }
    return wxMediaMessage;
}
 
开发者ID:xyzlf,项目名称:ShareSDK,代码行数:25,代码来源:ShareByWeixin.java

示例3: sharePicture

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
private void sharePicture(int shareType, Message.Picture message) {
    Bitmap bitmap = message.getImage();
    Bitmap thumbImage = Bitmap.createScaledBitmap(bitmap, THUMB_SIZE, THUMB_SIZE, false);
    WXImageObject imgObj = new WXImageObject(bitmap);
    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = imgObj;
    if (thumbImage != null) {
        msg.setThumbImage(thumbImage);
    }
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = ShareUtil.buildTransaction("imgshareappdata");
    req.message = msg;
    req.scene = shareType;
    mIWXAPI.sendReq(req);

}
 
开发者ID:henjue,项目名称:sharesdk,代码行数:17,代码来源:WechatShareManager.java

示例4: shareWebPage

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
private void shareWebPage(int shareType, Message.Web message) {

        WXWebpageObject webpage = new WXWebpageObject();
        webpage.webpageUrl = message.getURL();
        WXMediaMessage msg = new WXMediaMessage(webpage);
        msg.title = message.getTitle();
        msg.description = message.getDescription();

        Bitmap bmp = Bitmap.createScaledBitmap(message.getImage(), THUMB_SIZE, THUMB_SIZE, true);
        if (bmp == null) {
            Toast.makeText(mContext, R.string.share_pic_empty,
                    Toast.LENGTH_SHORT).show();
        } else {
            msg.setThumbImage(bmp);
        }

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = ShareUtil.buildTransaction("webpage");
        req.message = msg;
        req.scene = shareType;
        mIWXAPI.sendReq(req);
    }
 
开发者ID:henjue,项目名称:sharesdk,代码行数:23,代码来源:WechatShareManager.java

示例5: shareMusic

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
private void shareMusic(int shareType, Message.Music message) {

        WXMusicObject music = new WXMusicObject();
        //Str1+"#wechat_music_url="+str2 ;str1是网页地址,str2是音乐地址。

        music.musicUrl = message.getURL() + "#wechat_music_url=" + message.getMusicUrl();
        WXMediaMessage msg = new WXMediaMessage(music);
        msg.title = message.getTitle();
        msg.description = message.getDescription();

        Bitmap thumb = Bitmap.createScaledBitmap(message.getImage(), THUMB_SIZE, THUMB_SIZE, true);
        if (thumb == null) {
            Toast.makeText(mContext, R.string.share_pic_empty,
                    Toast.LENGTH_SHORT).show();
        } else {
            msg.setThumbImage(thumb);
        }

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = ShareUtil.buildTransaction("music");
        req.message = msg;
        req.scene = shareType;
        mIWXAPI.sendReq(req);
    }
 
开发者ID:henjue,项目名称:sharesdk,代码行数:25,代码来源:WechatShareManager.java

示例6: shareByWeixin

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
/**
 * 微信分享
 * 
 * @param flag
 *            0:微信好友;1:微信朋友圈
 */
private void shareByWeixin(int flag) {
	WXWebpageObject webpage = new WXWebpageObject();
	webpage.webpageUrl = webUrl;
	WXMediaMessage msg = new WXMediaMessage(webpage);
	msg.title = title;
	msg.description = "听讯信息科技有限责任公司官网";
	// 这里替换一张自己工程里的图片资源
	Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
	msg.setThumbImage(thumb);
	SendMessageToWX.Req req = new SendMessageToWX.Req();
	req.transaction = String.valueOf(System.currentTimeMillis());
	req.message = msg;
	req.scene = flag == 0 ? SendMessageToWX.Req.WXSceneSession : SendMessageToWX.Req.WXSceneTimeline;
	wxApi.sendReq(req);

}
 
开发者ID:tincent,项目名称:libtincent,代码行数:23,代码来源:WebviewActivity.java

示例7: sendTextMsgToWx

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
public static void sendTextMsgToWx(Context context, String title,
                                   String description, String url, Bitmap picture, boolean isToTimeline) {
    if (!hasRegistered) {
        regToWx(context);
    }
    if(!api.isWXAppInstalled()){
        Toast.makeText(context, "分享失败,没有安装微信客户端", Toast.LENGTH_SHORT).show();
        return;
    }
    WXTextObject textObj = new WXTextObject(description);
    final SendMessageToWX.Req req = new SendMessageToWX.Req();
    if (isToTimeline) {
        req.scene = SendMessageToWX.Req.WXSceneTimeline;
    } else {
        req.scene = SendMessageToWX.Req.WXSceneSession;
    }

    final WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = textObj;
    msg.description = description;
    msg.title = title;
    msg.setThumbImage(picture);
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg;
    api.sendReq(req);
}
 
开发者ID:fatsoon,项目名称:UniversalCommunityAccount,代码行数:27,代码来源:UCAWeixinUtils.java

示例8: shareWebUrlWithIcon

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
public void shareWebUrlWithIcon(Bitmap icon, String shareUrl, String title, String desc,
                              boolean shareToFriendCircle, IWXShareCallback callback) {
    final String id = buildTransaction("web_url");
    WXWebpageObject webObj = new WXWebpageObject();
    webObj.webpageUrl = shareUrl;
    webObj.extInfo = "this is extInfo";

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = webObj;
    msg.title = title;
    msg.description = desc;
    msg.setThumbImage(icon);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = id;
    req.message = msg;
    req.scene = shareToFriendCircle ? SendMessageToWX.Req.WXSceneTimeline
            : SendMessageToWX.Req.WXSceneSession;

    mCallbackMap.put(req.transaction.hashCode(),callback);
    mWxApi.sendReq(req);
}
 
开发者ID:LightSun,项目名称:android-common-utils,代码行数:23,代码来源:WeixinHelper.java

示例9: sendToWeiXin

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
public static void sendToWeiXin(IWXAPI wxApi, String url, String title, String desc, Bitmap bitmap) {
    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = title;
    msg.description = desc;
    msg.setThumbImage(bitmap);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg;
    req.scene = 0;
    wxApi.sendReq(req);
}
 
开发者ID:ChyengJason,项目名称:NanCanOlympic,代码行数:15,代码来源:ShareUtil.java

示例10: sendToCircle

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
public static void sendToCircle(IWXAPI wxApi, String url, String title, String desc, Bitmap bitmap) {
    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = title;
    msg.description = desc;
    msg.setThumbImage(bitmap);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg;
    req.scene = 1;
    wxApi.sendReq(req);
}
 
开发者ID:ChyengJason,项目名称:NanCanOlympic,代码行数:15,代码来源:ShareUtil.java

示例11: onActivityResult

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch (requestCode) {

	case 0x101: {
		final WXAppExtendObject appdata = new WXAppExtendObject();
		final String path = CameraUtil.getResultPhotoPath(this, data, SDCARD_ROOT + "/tencent/");
		appdata.filePath = path;
		appdata.extInfo = "this is ext info";

		final WXMediaMessage msg = new WXMediaMessage();
		msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true));
		msg.title = "this is title";
		msg.description = "this is description";
		msg.mediaObject = appdata;
		
		SendMessageToWX.Req req = new SendMessageToWX.Req();
		req.transaction = buildTransaction("appdata");
		req.message = msg;
		req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
		req.openId = getOpenId();
		api.sendReq(req);
		
		finish();
		break;
	}
	default:
		break;
	}
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:33,代码来源:SendToWXActivity.java

示例12: onActivityResult

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch (requestCode) {
	case 0x100: {
		if (resultCode == RESULT_OK) {
			final WXAppExtendObject appdata = new WXAppExtendObject();
			final String path = CameraUtil.getResultPhotoPath(this, data, "/mnt/sdcard/tencent/");
			appdata.filePath = path;
			appdata.extInfo = "this is ext info";

			final WXMediaMessage msg = new WXMediaMessage();
			msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true));
			msg.title = "this is title";
			msg.description = "this is description";
			msg.mediaObject = appdata;

			
			GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp();
			resp.transaction = getTransaction();
			resp.message = msg;
			
			api.sendResp(resp);
			finish();
		}
		break;
	}

	default:
		break;
	}
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:34,代码来源:GetFromWXActivity.java

示例13: onActivityResult

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch (requestCode) {

	case 0x101: {
		final WXAppExtendObject appdata = new WXAppExtendObject();
		final String path = CameraUtil.getResultPhotoPath(this, data, SDCARD_ROOT + "/tencent/");
		appdata.filePath = path;
		appdata.extInfo = "this is ext info";

		final WXMediaMessage msg = new WXMediaMessage();
		msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true));
		msg.title = "this is title";
		msg.description = "this is description";
		msg.mediaObject = appdata;
		
		SendMessageToWX.Req req = new SendMessageToWX.Req();
		req.transaction = buildTransaction("appdata");
		req.message = msg;
		req.scene = SendMessageToWX.Req.WXSceneFavorite;
		req.openId = getOpenId();
		api.sendReq(req);
		
		finish();
		break;
	}
	default:
		break;
	}
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:33,代码来源:AddFavoriteToWXActivity.java

示例14: shareAppToWeiXin

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
private static void shareAppToWeiXin(int type) {
    WXWebpageObject webObject = new WXWebpageObject();
    webObject.webpageUrl = APK_PAGE;

    WXMediaMessage msg = new WXMediaMessage(webObject);
    msg.title = baseContext.getString(R.string.share_app_title);
    msg.description = baseContext.getString(R.string.app_introduce);

    Bitmap bitmap = BitmapFactory.decodeResource(baseContext.getResources(), R.drawable.logo);
    msg.setThumbImage(bitmap);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg;
    req.scene = type;

    if (wxapi.sendReq(req)) {
        shareSuccess();
        if (type == SendMessageToWX.Req.WXSceneSession) {
            StatUtils.onShareEvent(StatUtils.EVENT_SHARE_APP, StatUtils.SHARE_WEIXIN_FRIEND);
        } else {
            StatUtils.onShareEvent(StatUtils.EVENT_SHARE_APP, StatUtils.SHARE_WEIXIN_CIRCLE);
        }
    } else {
        shareFail();
    }
}
 
开发者ID:CyanFlxy,项目名称:KnockKnock,代码行数:28,代码来源:ShareUtil.java

示例15: a

import com.tencent.mm.sdk.modelmsg.WXMediaMessage; //导入方法依赖的package包/类
private boolean a(String s1, boolean flag)
{
    if (!t.isWXAppInstalled())
    {
        CustomToast.makeText(this, 0x7f0d017d, 0).show();
        return false;
    }
    WXImageObject wximageobject = new WXImageObject();
    wximageobject.setImagePath(s1);
    android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options();
    options.inSampleSize = 4;
    M = BitmapFactory.decodeFile(s1, options);
    WXMediaMessage wxmediamessage = new WXMediaMessage();
    wxmediamessage.mediaObject = wximageobject;
    wxmediamessage.title = v;
    wxmediamessage.description = w;
    if (M != null)
    {
        wxmediamessage.setThumbImage(M);
    }
    com.tencent.mm.sdk.modelmsg.SendMessageToWX.Req req = new com.tencent.mm.sdk.modelmsg.SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = wxmediamessage;
    int i1 = 0;
    if (flag)
    {
        i1 = 1;
    }
    req.scene = i1;
    return t.sendReq(req);
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:32,代码来源:ShareActivity.java


注:本文中的com.tencent.mm.sdk.modelmsg.WXMediaMessage.setThumbImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。