• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SendMessageToWX类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tencent.mm.opensdk.modelmsg.SendMessageToWX的典型用法代码示例。如果您正苦于以下问题:Java SendMessageToWX类的具体用法?Java SendMessageToWX怎么用?Java SendMessageToWX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SendMessageToWX类属于com.tencent.mm.opensdk.modelmsg包,在下文中一共展示了SendMessageToWX类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onResp

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
    Log.e(TAG, "transaction = " + resp.transaction + ", type = " + resp.getType() + ", errCode = " + resp.errCode + ", err = " + resp.errStr);

    if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
        switch (resp.getType()) {
        case ConstantsAPI.COMMAND_SENDAUTH:
            onResultOk((SendAuth.Resp) resp);
            break;
        case ConstantsAPI.COMMAND_PAY_BY_WX:
            onResultOk((PayResp) resp);
            break;
        case ConstantsAPI.COMMAND_SENDMESSAGE_TO_WX:
            onResultOk((SendMessageToWX.Resp) resp);
            break;
        }
    } else if (resp.errCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
        mCallback.onFailed(mActivity, ResultCode.RESULT_CANCELLED, toMessage(resp));
    } else {
        mCallback.onFailed(mActivity, ResultCode.RESULT_FAILED, toMessage(resp));
    }
    mCallback.onCompleted(mActivity);
}
 
开发者ID:czy1121,项目名称:sdk3rd,代码行数:24,代码来源:WXBase.java


示例2: shareToWX

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
/**
 * @param flag
 * 0 发送到会话
 * 1 发送到朋友圈
 */
private int shareToWX(int flag){
    String text = mDetailItem.getUserName()+"说: "+mDetailItem.getRantContent()+" " + "\n目前有"+mDetailItem.getCommentList().size()+"人围观,来凑个热闹吧!";
    final IWXAPI iwxapi = WXAPIFactory.createWXAPI(this, getString(R.string.app_id));
    iwxapi.registerApp(getString(R.string.app_id));
    if(!iwxapi.isWXAppInstalled()){
        Toast.makeText(this, "你还没有安装微信", Toast.LENGTH_SHORT).show();
        return 0;
    }

    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = getString(R.string.ip_server)+"rant.action?rantId="+mDetailItem.getRantId();
    final WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = "Rant社区";
    msg.description = text;

    final SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.scene = flag;
    final Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    msg.setThumbImage(logo);
    req.message = msg;
    iwxapi.sendReq(req);
    return 1;
}
 
开发者ID:shawnsky,项目名称:RantApp,代码行数:30,代码来源:RantActivity.java


示例3: share

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@Override
public void share(final int shareId) {
    mapObject.captureMap(new IMapCaptureFinished() {
        @Override
        public void onMapCaptureFinished(Bitmap bitmap, int status) {
            WXImageObject imageObject = new WXImageObject(bitmap);

            WXMediaMessage mediaMessage = new WXMediaMessage();
            mediaMessage.mediaObject = imageObject;
            Bitmap thumb = Bitmap.createScaledBitmap(bitmap,50,50,true);
            bitmap.recycle();
            mediaMessage.thumbData = ShareUtils.bmpToByteArray(thumb,true);
            SendMessageToWX.Req req = new SendMessageToWX.Req();
            req.transaction = ShareUtils.buildTransaction("img");
            req.message = mediaMessage;
            if(shareId == R.id.btn_share_to_friend){
                req.scene = SendMessageToWX.Req.WXSceneSession;
            }
            else{
                req.scene = SendMessageToWX.Req.WXSceneTimeline;
            }
            CFLog.e("Share","send = "+ mWxApi.sendReq(req));
        }
    });
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:26,代码来源:TrackPresenterImpl.java


示例4: clickShare

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@OnClick(R.id.tv_me_share) void clickShare() {
    android.app.AlertDialog.Builder builder=new android.app.AlertDialog.Builder(getActivity());
    builder.setIcon(R.mipmap.app_icon);
    builder.setTitle("爱分享的人运气总不会差");
    builder.setItems(R.array.shareList, new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int which) {
            int scene = SendMessageToWX.Req.WXSceneSession;
            if(which == 1) {
                scene = SendMessageToWX.Req.WXSceneTimeline;
            }else if(which == 2){
                scene = SendMessageToWX.Req.WXSceneFavorite;
            }
            ShareUtils.install(getActivity());
            ShareUtils.shareWeb(getActivity(),getResources().getString(R.string.app_name)+",你的掌上校园伴侣","广财专用APP,学生开发,课表饭卡校园网,一样不少",AppConfig.WXSHARE_URL, scene);
        }
    });
    builder.create().show();
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:19,代码来源:MeFragment.java


示例5: shareWeb

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareWeb(Context context,String title,String desc,String url,@Scene int scene){
    if (!checkForSupport(context)) return;
    WXWebpageObject webPage = new WXWebpageObject();
    webPage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webPage);
    msg.title = title;
    msg.description = desc;
    Bitmap thumb = BitmapFactory.decodeResource(context.getResources(), R.mipmap.app_icon_64);
    msg.thumbData = bmpToByteArray(thumb);

    // 如果分享到朋友圈需要校验是否支持
    if (scene == SendMessageToWX.Req.WXSceneTimeline && !checkTimeLine(context)) return;

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction(scene);
    req.message = msg;
    req.scene = scene;
    boolean sendReq = api.sendReq(req);
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:20,代码来源:ShareUtils.java


示例6: WXHandler

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public WXHandler() {
    this.mEventHandler = new IWXAPIEventHandler() {
        public void onResp(BaseResp resp) {
            if(!mLastTransaction.equals(resp.transaction)) {
                return;
            }

            int type = resp.getType();
            switch(type) {
                case ConstantsAPI.COMMAND_SENDAUTH:     //授权返回
                    WXHandler.this.onAuthCallback((SendAuth.Resp)resp);
                    break;

                case ConstantsAPI.COMMAND_SENDMESSAGE_TO_WX:        //分享返回
                    WXHandler.this.onShareCallback((SendMessageToWX.Resp)resp);
                    break;
            }

        }

        public void onReq(BaseReq req) {
        }
    };
}
 
开发者ID:tsy12321,项目名称:SocialSDKAndroid,代码行数:25,代码来源:WXHandler.java


示例7: onShareCallback

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
protected void onShareCallback(com.tencent.mm.opensdk.modelmsg.SendMessageToWX.Resp resp) {
    switch (resp.errCode) {
        case BaseResp.ErrCode.ERR_OK:       //分享成功
            if(this.mShareListener != null) {
                this.mShareListener.onComplete(this.mConfig.getName());
            }
            break;

        case BaseResp.ErrCode.ERR_USER_CANCEL:      //分享取消
            if(this.mShareListener != null) {
                this.mShareListener.onCancel(this.mConfig.getName());
            }
            break;

        default:    //分享失败
            CharSequence err = TextUtils.concat(new CharSequence[]{"weixin share error (", String.valueOf(resp.errCode), "):", resp.errStr});
            if(mShareListener != null) {
                mShareListener.onError(this.mConfig.getName(), err.toString());
            }
            break;
    }
}
 
开发者ID:tsy12321,项目名称:SocialSDKAndroid,代码行数:23,代码来源:WXHandler.java


示例8: shareText

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@Override
protected void shareText(final ShareParamText params) throws ShareException {
    String text = params.getContent();
    if (TextUtils.isEmpty(text)) {
        throw new InvalidParamException("Content is empty or illegal");
    }

    WXTextObject textObj = new WXTextObject();
    textObj.text = text;

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = textObj;
    msg.description = text;

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("textshare");
    req.message = msg;
    req.scene = getShareType();
    Log.d(TAG, "start share text");
    shareOnMainThread(req);
}
 
开发者ID:Bilibili,项目名称:BiliShare,代码行数:22,代码来源:BaseWxShareHandler.java


示例9: shareImage

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@Override
protected void shareImage(final ShareParamImage params) throws ShareException {
    mImageHelper.downloadImageIfNeed(params, new Runnable() {
        @Override
        public void run() {
            WXImageObject imgObj = buildWXImageObject(params.getImage());

            WXMediaMessage msg = new WXMediaMessage();
            msg.mediaObject = imgObj;
            msg.thumbData = mImageHelper.buildThumbData(params.getImage());

            final SendMessageToWX.Req req = new SendMessageToWX.Req();
            req.transaction = buildTransaction("imgshareappdata");
            req.message = msg;
            req.scene = getShareType();
            Log.d(TAG, "start share image");
            shareOnMainThread(req);
        }
    });
}
 
开发者ID:Bilibili,项目名称:BiliShare,代码行数:21,代码来源:BaseWxShareHandler.java


示例10: buildTransaction

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
/**
 * 根据scene创建一个transaction字符串,从微信返回的时候会携带这个字符串
 * @param scene
 * @return
 */
private static String buildTransaction(@Scene int scene) {
    String tag = null;
    if (scene == SendMessageToWX.Req.WXSceneSession){
        tag = TAG_SESSION;
    }else if (scene == SendMessageToWX.Req.WXSceneTimeline){
        tag = TAG_TIMELINE;
    }else if (scene == SendMessageToWX.Req.WXSceneFavorite){
        tag = TAG_FAVORITE;
    }else {
        // can't reach
        tag = TAG_UNKNOWN;
    }
    return tag + System.currentTimeMillis();
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:20,代码来源:ShareUtils.java


示例11: getShareToWhere

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
private int getShareToWhere(int shareTarget) {
    int where = SendMessageToWX.Req.WXSceneSession;
    switch (shareTarget) {
        case Target.SHARE_WX_FRIENDS:
            where = SendMessageToWX.Req.WXSceneSession;
            break;
        case Target.SHARE_WX_ZONE:
            where = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Target.SHARE_WX_FAVORITE:
            where = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }
    return where;
}
 
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:16,代码来源:WxPlatform.java


示例12: sendMsgToWx

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
private void sendMsgToWx(WXMediaMessage msg, int shareTarget, String sign) {
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction(sign);
    req.message = msg;
    req.scene = getShareToWhere(shareTarget);
    boolean sendResult = mWxApi.sendReq(req);
    if (!sendResult) {
        mOnShareListener.onFailure(new SocialException("sendMsgToWx失败,可能是参数错误"));
    }
}
 
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:11,代码来源:WxPlatform.java


示例13: shareText

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareText(Context context, String scene) {

        //注册微信
        registerWX(context);
        //构建文本分享消息并发送分享
        WXTextObject wxTextObject = new WXTextObject();
        wxTextObject.text = "你好";

        WXMediaMessage message = new WXMediaMessage();
        message.mediaObject = wxTextObject;
        message.description ="随便逛逛";

        //构造一个REQ
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = buildTransaction("text");
        req.message = message;

        if (scene.equalsIgnoreCase("session")) {
            req.scene = SendMessageToWX.Req.WXSceneSession;
        } else if (scene.equalsIgnoreCase("timeline")) {
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
        } else if (scene.equalsIgnoreCase("favorite")) {
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
        }

        //调用API接口
        api.sendReq(req);

    }
 
开发者ID:haihaio,项目名称:AmenWeather,代码行数:30,代码来源:WXEntryActivityUtils.java


示例14: sendMessage

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
private void sendMessage(int platform, WXMediaMessage message, String transaction) {
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = transaction;
    req.message = message;
    req.scene = platform == SharePlatform.WX_TIMELINE ? SendMessageToWX.Req.WXSceneTimeline
            : SendMessageToWX.Req.WXSceneSession;
    mIWXAPI.sendReq(req);
}
 
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:9,代码来源:WxShareInstance.java


示例15: shareText

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareText(String text, SharePlace sharePlace) {
    WXTextObject wxTextObject = new WXTextObject();
    wxTextObject.text = text;

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = wxTextObject;
    msg.description = text;

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = WechatPayTools.getCurrTime();

    req.message = msg;
    switch (sharePlace) {
        case Friend:
            req.scene = SendMessageToWX.Req.WXSceneSession;
            break;
        case Zone:
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Favorites:
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }

    if (iwxapi != null) {
        iwxapi.sendReq(req);
    } else {
        throw new NullPointerException("请先调用WechatShare.init()方法");
    }
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:31,代码来源:WechatShareTools.java


示例16: shareImage

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareImage(Bitmap bitmap, SharePlace sharePlace) {
    WXImageObject wxImageObject = new WXImageObject(bitmap);
    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = wxImageObject;

    Bitmap thumbBmp = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
    bitmap.recycle();
    msg.thumbData = RxImageTool.bitmap2Bytes(thumbBmp, Bitmap.CompressFormat.PNG);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = WechatPayTools.getCurrTime();

    req.message = msg;
    switch (sharePlace) {
        case Friend:
            req.scene = SendMessageToWX.Req.WXSceneSession;
            break;
        case Zone:
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Favorites:
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }

    if (iwxapi != null) {
        iwxapi.sendReq(req);
    } else {
        throw new NullPointerException("请先调用WechatShare.init()方法");
    }
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:32,代码来源:WechatShareTools.java


示例17: shareMusic

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareMusic(WechatShareModel shareModel, SharePlace sharePlace) {
    WXMusicObject wxMusicObject = new WXMusicObject();
    wxMusicObject.musicUrl = shareModel.getUrl();

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = wxMusicObject;
    msg.title = shareModel.getTitle();
    msg.description = shareModel.getDescription();

    msg.thumbData = shareModel.getThumbData();

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = WechatPayTools.getCurrTime();
    req.message = msg;

    switch (sharePlace) {
        case Friend:
            req.scene = SendMessageToWX.Req.WXSceneSession;
            break;
        case Zone:
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Favorites:
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }

    if (iwxapi != null) {
        iwxapi.sendReq(req);
    } else {
        throw new NullPointerException("请先调用WechatShare.init()方法");
    }
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:34,代码来源:WechatShareTools.java


示例18: shareVideo

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareVideo(WechatShareModel shareModel, SharePlace sharePlace) {
    WXVideoObject wxVideoObject = new WXVideoObject();
    wxVideoObject.videoUrl = shareModel.getUrl();

    WXMediaMessage msg = new WXMediaMessage(wxVideoObject);
    msg.title = shareModel.getTitle();
    msg.description = shareModel.getDescription();

    msg.thumbData = shareModel.getThumbData();

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = WechatPayTools.getCurrTime();
    req.message = msg;

    switch (sharePlace) {
        case Friend:
            req.scene = SendMessageToWX.Req.WXSceneSession;
            break;
        case Zone:
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Favorites:
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }

    if (iwxapi != null) {
        iwxapi.sendReq(req);
    } else {
        throw new NullPointerException("请先调用WechatShare.init()方法");
    }
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:33,代码来源:WechatShareTools.java


示例19: shareURL

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
public static void shareURL(WechatShareModel shareModel, SharePlace sharePlace) {
    WXWebpageObject webpageObject = new WXWebpageObject();
    webpageObject.webpageUrl = shareModel.getUrl();

    WXMediaMessage msg = new WXMediaMessage(webpageObject);
    msg.title = shareModel.getTitle();
    msg.description = shareModel.getDescription();

    msg.thumbData = shareModel.getThumbData();

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = WechatPayTools.getCurrTime();
    req.message = msg;

    switch (sharePlace) {
        case Friend:
            req.scene = SendMessageToWX.Req.WXSceneSession;
            break;
        case Zone:
            req.scene = SendMessageToWX.Req.WXSceneTimeline;
            break;
        case Favorites:
            req.scene = SendMessageToWX.Req.WXSceneFavorite;
            break;
    }

    if (iwxapi != null) {
        iwxapi.sendReq(req);
    } else {
        throw new NullPointerException("请先调用WechatShare.init()方法");
    }
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:33,代码来源:WechatShareTools.java


示例20: shareWebPage

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; //导入依赖的package包/类
@Override
protected void shareWebPage(final ShareParamWebPage params) throws ShareException {
    if (TextUtils.isEmpty(params.getTargetUrl())) {
        throw new InvalidParamException("Target url is empty or illegal");
    }

    mImageHelper.downloadImageIfNeed(params, new Runnable() {
        @Override
        public void run() {

            WXWebpageObject webpage = new WXWebpageObject();
            webpage.webpageUrl = params.getTargetUrl();

            WXMediaMessage msg = new WXMediaMessage(webpage);
            msg.title = params.getTitle();
            msg.description = params.getContent();
            msg.thumbData = mImageHelper.buildThumbData(params.getThumb());

            SendMessageToWX.Req req = new SendMessageToWX.Req();
            req.transaction = buildTransaction("webpage");
            req.message = msg;
            req.scene = getShareType();
            Log.d(TAG, "start share webpage");
            shareOnMainThread(req);
        }
    });
}
 
开发者ID:Bilibili,项目名称:BiliShare,代码行数:28,代码来源:BaseWxShareHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BoundaryException类代码示例发布时间:2022-05-22
下一篇:
Java TShortSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap