本文整理汇总了Java中com.tencent.mm.sdk.modelmsg.WXWebpageObject类的典型用法代码示例。如果您正苦于以下问题:Java WXWebpageObject类的具体用法?Java WXWebpageObject怎么用?Java WXWebpageObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WXWebpageObject类属于com.tencent.mm.sdk.modelmsg包,在下文中一共展示了WXWebpageObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shareToWeChat
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
public static void shareToWeChat(final Context context, final String appId, final String title, final String desc,
final String url, final String thumbnail, final IWXShareCallback callback) {
new Thread(new Runnable() {
@Override
public void run() {
WeChatShareProxy.mCallback = callback;
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = url;
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = title;
msg.description = desc;
byte[] thumb = SocialUtils.getHtmlByteArray(thumbnail);
if (null != thumb)
msg.thumbData = SocialUtils.compressBitmap(thumb, 32);
else
msg.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = SocialUtils.buildTransaction("webpage");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneSession;
WeChat.getIWXAPIInstance(context, appId).sendReq(req);
}
}).start();
}
示例2: shareToWeChatTimeline
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
public static void shareToWeChatTimeline(final Context context, final String appId, final String title, final String url,
final String thumbnail, final IWXShareCallback callback) {
new Thread(new Runnable() {
@Override
public void run() {
WeChatShareProxy.mCallback = callback;
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = url;
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = title;
byte[] thumb = SocialUtils.getHtmlByteArray(thumbnail);
if (null != thumb)
msg.thumbData = SocialUtils.compressBitmap(thumb, 32);
else
msg.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = SocialUtils.buildTransaction("webpage");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneTimeline;
WeChat.getIWXAPIInstance(context, appId).sendReq(req);
}
}).start();
}
示例3: shareToWX
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
public static void shareToWX(final ShareInfo shareInfo, final int scene, Bitmap bitmap) {
//构建一个WXWebpageObject对象,用于封装要分享的链接Url地址
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = shareInfo.getLink();
//构建一个WXMediaMessage对象,用于封装分享链接Url信息的标题与描述
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = shareInfo.getTitle();
msg.description = shareInfo.getDesc();
msg.thumbData = bitmap2Bytes(bitmap, 30);
//构建一个微信请求
SendMessageToWX.Req reqs = new SendMessageToWX.Req();
reqs.message = msg;
reqs.transaction = buildTransaction("webpage");
reqs.scene = scene == 1 ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
MyApplication.api.sendReq(reqs);
}
示例4: send
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
private boolean send(String title, String content, String url, int iconResId, int scene) {
if (wxapi.getWXAppSupportAPI() < 0x21020001) {
return false;
}
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = url;
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = title;
msg.description = content;
Bitmap bmp = BitmapFactory.decodeResource(BaseApplication.getContext().getResources(), iconResId);
Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 150, 150, true);
bmp.recycle();
msg.thumbData = ImageUtil.bitmapToByteArray(thumbBmp, 100);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage");
req.message = msg;
req.scene = scene;
// 调用api接口发送数据到微信
return wxapi.sendReq(req);
}
示例5: shareHypeLink
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}
示例6: buildWXMediaMessage
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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;
}
示例7: shareToWX
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
/**
* 分享到微信
*/
static void shareToWX(Activity activity, int which, ShareContent shareContent) {
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = shareContent.getLinkUrl();
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = shareContent.getTitle();
msg.description = shareContent.getSummary();
Bitmap thumb = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_logo);
msg.thumbData = BitmapUtil.compress(thumb, CompressFormat.PNG);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage");
req.message = msg;
if (1 == which) {
msg.title = shareContent.getSummary();
req.scene = SendMessageToWX.Req.WXSceneTimeline;
} else if (0 == which) {
req.scene = SendMessageToWX.Req.WXSceneSession;
}
IWXAPI api = MyApp.getApp().getWXAPI();
api.sendReq(req);
}
示例8: shareWebPage
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}
示例9: share
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
@Override
public void share() {
if (App.getWechatAppId() == null) {
if (mListener != null) {
mListener.onError(this);
}
}
IWXAPI api = WXAPIFactory.createWXAPI(mContext, App.getWechatAppId(), false);
if (!api.isWXAppInstalled()) {
if (mListener != null) {
mListener.onError(this);
}
return;
}
WXWebpageObject web = new WXWebpageObject();
web.webpageUrl = mUrl;
WXMediaMessage msg = new WXMediaMessage(web);
msg.title = mTitle;
msg.description = mText;
msg.thumbData = AppUtil.toByteArray(AppUtil.getAppIcon(mContext));
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = TRANSACTION + System.currentTimeMillis();
req.message = msg;
req.scene = getScene();
api.sendReq(req);
}
示例10: shareByWeixin
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}
示例11: shareWebUrlWithIcon
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}
示例12: sendMsgToWX
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
private static void sendMsgToWX(SceneType type) {
WXWebpageObject webpageObject = new WXWebpageObject();
webpageObject.webpageUrl = "www.zepp.com";
WXMediaMessage msg = new WXMediaMessage(webpageObject);
msg.title = "网页标题";
msg.title = "网页描述";
//msg.setThumbImage();
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage");
req.message = msg;
if(type == SceneType.WXSceneSession) {
req.scene = SendMessageToWX.Req.WXSceneSession;
} else if(type == SceneType.WXSceneTimeline) {
req.scene = SendMessageToWX.Req.WXSceneTimeline;
} else {
req.scene = SendMessageToWX.Req.WXSceneFavorite;
}
}
示例13: doShareWebPage
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
private static void doShareWebPage(final String url,final String title,final String desc,final String img,final boolean timelined) {
if(api==null) {
api= WXAPIFactory.createWXAPI(MainApp.getContext(), APP_ID);
}
Bitmap bitmap= ImageUtil.getBitmap(img);
Bitmap thumb =null;
if(bitmap!=null){
thumb=Bitmap.createScaledBitmap(bitmap, 64, 64, true);
}
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = url;
WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = title;
msg.description = desc;
if(thumb!=null) {
msg.thumbData = BitmapUtil.bmpToByteArray(thumb, true);
}else{
Bitmap thumbIcon = BitmapFactory.decodeResource(MainApp.getInstance().getResources(), R.drawable.icon);
msg.thumbData = BitmapUtil.bmpToByteArray(thumbIcon, true);
}
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage");
req.message = msg;
req.scene = timelined ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
api.sendReq(req);
}
示例14: sendToWeiXin
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}
示例15: sendToCircle
import com.tencent.mm.sdk.modelmsg.WXWebpageObject; //导入依赖的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);
}