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


Java WXWebpageObject类代码示例

本文整理汇总了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();

}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:27,代码来源:WeChatShareProxy.java

示例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();

}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:26,代码来源:WeChatShareProxy.java

示例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);
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:19,代码来源:ShareUtils.java

示例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);
    }
 
开发者ID:joy-inc,项目名称:joy-library,代码行数:27,代码来源:ShareWeixinUtil.java

示例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);
}
 
开发者ID:markzhai,项目名称:AndroidProjectFrom0,代码行数:32,代码来源:WeChatSharePlugin.java

示例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;
}
 
开发者ID:xyzlf,项目名称:ShareSDK,代码行数:25,代码来源:ShareByWeixin.java

示例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);
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:28,代码来源:ShareUtils.java

示例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);
    }
 
开发者ID:henjue,项目名称:sharesdk,代码行数:23,代码来源:WechatShareManager.java

示例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);
}
 
开发者ID:wavinsun,项目名称:MUtils,代码行数:27,代码来源:ShareWechatImpl.java

示例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);

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

示例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);
}
 
开发者ID:LightSun,项目名称:android-common-utils,代码行数:23,代码来源:WeixinHelper.java

示例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;
    }
}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:21,代码来源:WeChatManager.java

示例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);
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:31,代码来源:WeixinShareApi.java

示例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);
}
 
开发者ID:ChyengJason,项目名称:NanCanOlympic,代码行数:15,代码来源:ShareUtil.java

示例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);
}
 
开发者ID:ChyengJason,项目名称:NanCanOlympic,代码行数:15,代码来源:ShareUtil.java


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