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


Java WXImageObject类代码示例

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


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

示例1: sendImage

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private void sendImage() {
    switch (instance.api) {
        case QQ:
            String appName = mContext.getString(R.string.app_name);
            Bundle params = QQUtils.genImgMsg(appName, title, description, qqTagetUrl, qqImgUrl, qqFilePath);
            configInstance.getTencentApi().shareToQQ((Activity) mContext, params, new QQCallbackListener());
            return;
        case WeChat:
            WXImageObject imgObj = new WXImageObject();
            Bitmap thumbBmp = Bitmap.createScaledBitmap(wxImgBmp, THUMB_SIZE, THUMB_SIZE, true);
            wxImgBmp.recycle();
            WXMediaMessage msg = WxUtils.genMsg(imgObj, title, description, thumbBmp);

            // 调用api接口发送数据到微信
            configInstance.getWxApi().sendReq(WxUtils.genRequest(msg, instance.type));
            return;
        case SinaWeiBo:
            return;
    }
}
 
开发者ID:Jay-Y,项目名称:share,代码行数:21,代码来源:ShareUtil.java

示例2: shareToWechat

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private static void shareToWechat(String transaction, Activity activity, String title, String summary, Bitmap img, int flag) {
    IWXAPI wxApi = getWxApi();

    WXImageObject imgObj = new WXImageObject(img);

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = imgObj;

    //Bitmap thumbBmp = Bitmap.createScaledBitmap(img, THUMB_SIZE, THUMB_SIZE, true);
    msg.thumbData = bmpToThumbArray(img);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = transaction;
    req.message = msg;
    req.scene = flag;
    wxApi.sendReq(req);
}
 
开发者ID:qiujuer,项目名称:UPMiss,代码行数:18,代码来源:Share.java

示例3: sharePicture

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的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: sendImage

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private void sendImage(int type, Bitmap bitmap) {
    Bitmap thumb = getThumbBitmap(bitmap);

    WXImageObject imageObject = new WXImageObject(bitmap);
    WXMediaMessage msg = new WXMediaMessage(imageObject);
    msg.title = mShareOption.title;
    msg.description = mShareOption.description;
    msg.thumbData = Utils.bmpToByteArray(thumb, true);

    SendMessageToWX.Req request = new SendMessageToWX.Req();
    request.transaction = "image" + System.currentTimeMillis();
    request.message = msg;
    request.scene = type;

    mWXAPI.sendReq(request);
}
 
开发者ID:chenjishi,项目名称:wiping,代码行数:17,代码来源:ShareDialog.java

示例5: test

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private void test() {
    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    WXImageObject imgObj = new WXImageObject(bmp);

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = imgObj;

    Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 200, 200, true);
    bmp.recycle();
    msg.thumbData = BitmapUtils.bmpToByteArray(thumbBmp, true);  //

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = System.currentTimeMillis() + "";
    req.message = msg;
    req.scene = SendMessageToWX.Req.WXSceneSession;
    api.sendReq(req);
}
 
开发者ID:Leaking,项目名称:WeGit,代码行数:18,代码来源:UserInfoActivity.java

示例6: shareImageByPath

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
/***
 * @param path  the local image path
 */
public void shareImageByPath(String path,String title ,String desc,boolean shareToFriendCircle,IWXShareCallback callback){
    WXImageObject imgObj = new WXImageObject();
    imgObj.setImagePath(path);

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = imgObj;
    msg.title = title;
    msg.description = desc;

   // Bitmap bmp = BitmapFactory.decodeFile(path);
    Bitmap bmp = new ImageParser(0,0).parseToBitmap(path);
    Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
    bmp.recycle();
    msg.thumbData = Util.bitampToByteArray(thumbBmp);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("img");
    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,代码行数:27,代码来源:WeixinHelper.java

示例7: share

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
@Override
public void share(Activity activity, Bitmap shareBitmap, Bitmap thumbBitmap, int platform) {
    ShareType = ShareConstant.SHARE;
    this.platform = platform;

    if (activity == null)
        return;

    thumbBitmap = GlideBitmapFactory.decodeFile(savePath);

    if (api == null) {
        api = WXAPIFactory.createWXAPI(activity, BuildConfig.WECHAT_APP_ID, false);
        api.registerApp(BuildConfig.WECHAT_APP_ID);
    }

    WXMediaMessage msg = new WXMediaMessage();
    msg.thumbData = Util.bmpToByteArray(thumbBitmap, true);

    WXImageObject imgObj = new WXImageObject();
    imgObj.setImagePath(savePath);
    msg.mediaObject = imgObj;

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = "img" + System.currentTimeMillis();
    req.message = msg;

    if (platform == ShareConstant.SHARE_MEDIA.WECHAT) {
        req.scene = SendMessageToWX.Req.WXSceneSession;

    } else if (platform == ShareConstant.SHARE_MEDIA.WECHAT_CIRCLE) {
        req.scene = SendMessageToWX.Req.WXSceneTimeline;
    }

    api.sendReq(req);

    if (thumbBitmap != null) {
        thumbBitmap.recycle();
    }

}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:41,代码来源:ShareWechat.java

示例8: buildImageParams

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private WXMediaMessage buildImageParams() {
    parseImage(this.mShareMedia);
    WXImageObject imgObj = new WXImageObject();
    WXMediaMessage msg = buildMediaMessage();
    if (TextUtils.isEmpty((CharSequence) this.mExtraData.get("image_path_local"))) {
        imgObj.imageUrl = (String) this.mExtraData.get("image_path_url");
    } else {
        imgObj.imagePath = (String) this.mExtraData.get("image_path_local");
    }
    msg.mediaObject = imgObj;
    return msg;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:UMWXHandler.java

示例9: shareImage

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
public static boolean shareImage(Bitmap image, String title, String desc, Bitmap thumb, int scene) {
    if (!isAppInstalled())
        return false;

    WXImageObject imgObj = new WXImageObject();
    imgObj.imageData = BitmapHelper.compressJPEG(image, 80);

    return shareObject(imgObj, title, desc, thumb, scene);
}
 
开发者ID:iWay7,项目名称:BikeHelper,代码行数:10,代码来源:WXApiHelper.java

示例10: sharePic

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
private void sharePic(Bitmap bmp, Bitmap thumbBmp, boolean isTimeline) {


        WXImageObject imgObj = new WXImageObject();
        imgObj.imageData = bmpToBytes(bmp);

        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = imgObj;

        // 缩略图
        if (thumbBmp != null) {
            msg.thumbData = bmpToBytes(thumbBmp);
        } else if (bmp != null) {
            Bitmap thumb = ShareWechatUtils.extractThumbNail(bmp, THUMB_SIZE, THUMB_SIZE, true);
            if (thumb != null) {
                Logger.e("Share:", "图片不为null");
            }
//			msg.setThumbImage(thumb);
            msg.thumbData = bmpToBytes(thumb);
        }

        // 构造一个Req
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = ShareWechatUtils.buildTransaction("img");
        req.message = msg;

        req.scene = isTimeline ? SendMessageToWX.Req.WXSceneTimeline
                : SendMessageToWX.Req.WXSceneSession;
        mAPI.sendReq(req);
    }
 
开发者ID:markzhai,项目名称:AndroidProjectFrom0,代码行数:31,代码来源:WeChatSharePlugin.java

示例11: createMediaObject

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
@Override
protected WXMediaMessage.IMediaObject createMediaObject() {
	WXImageObject object = new WXImageObject();
	switch (getShareParams().getImage().getSource()) {
		case File:
			object.imagePath = getShareParams().getImage().getImageFile().getPath();
			break;
		case Bitmap:
		case Http:
			object.imageData = ShareImageUtils.getCompressData(getShareParams().getImage(), MAX_IMAGE_SIZE);
			thumbData = object.imageData;
			break;
	}
	return object;
}
 
开发者ID:Joy-Whale,项目名称:EasyShare,代码行数:16,代码来源:WeChatShareImageAndTextMessage.java

示例12: doInBackground

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
@Override
protected SendMessageToWX.Req doInBackground(Object... params) {
    final String url = (String) params[0];
    final String title = (String)params[1];
    final String desc = (String)params[2];
    final boolean shareToFriendCircle = (Boolean)params[3];
    final IWXShareCallback callback = (IWXShareCallback)params[4];

    WXImageObject imgObj = new WXImageObject();
    imgObj.imageUrl = url;

    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = imgObj;
    msg.title = title;
    msg.description = desc;

    final String transaction = buildTransaction("img");
    mCallbackMap.put(transaction.hashCode(), callback);
    try {
        Bitmap bmp = new ImageParser(0,0).parseToBitmap(IoUtil.getBytesFromStreamAndClose(
                new URL(url).openStream()));
        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
        bmp.recycle();
        msg.thumbData =  Util.bitampToByteArray(thumbBmp);

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = transaction;
        req.message = msg;
        req.scene = shareToFriendCircle ? SendMessageToWX.Req.WXSceneTimeline
                : SendMessageToWX.Req.WXSceneSession;
        return req ;
    } catch (IOException e) {
        e.printStackTrace();
    }
    SendMessageToWX.Req req2 = new SendMessageToWX.Req();
    req2.transaction = transaction;
    req2.message = null;
    return req2;
}
 
开发者ID:LightSun,项目名称:android-common-utils,代码行数:40,代码来源:WeixinHelper.java

示例13: a

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的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

示例14: shareImage

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
@Override
public void shareImage(final int platform, final ShareImageObject shareImageObject,
        final Activity activity, final ShareListener listener) {
    Observable.fromEmitter(new Action1<Emitter<Pair<Bitmap, byte[]>>>() {
        @Override
        public void call(Emitter<Pair<Bitmap, byte[]>> emitter) {
            try {
                String imagePath = ImageDecoder.decode(activity, shareImageObject);
                emitter.onNext(Pair.create(BitmapFactory.decodeFile(imagePath),
                        ImageDecoder.compress2Byte(imagePath, TARGET_SIZE, THUMB_SIZE)));
            } catch (Exception e) {
                emitter.onError(e);
            }
        }
    }, Emitter.BackpressureMode.BUFFER)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnRequest(new Action1<Long>() {
                @Override
                public void call(Long aLong) {
                    listener.shareRequest();
                }
            })
            .subscribe(new Action1<Pair<Bitmap, byte[]>>() {
                @Override
                public void call(Pair<Bitmap, byte[]> pair) {
                    WXImageObject imageObject = new WXImageObject(pair.first);

                    WXMediaMessage message = new WXMediaMessage();
                    message.mediaObject = imageObject;
                    message.thumbData = pair.second;

                    sendMessage(platform, message, buildTransaction("image"));
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    activity.finish();
                    listener.shareFailure(new Exception(throwable));
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:WxShareInstance.java

示例15: shareImg

import com.tencent.mm.sdk.modelmsg.WXImageObject; //导入依赖的package包/类
public void shareImg(Bitmap bitmap, OnShareListener listener) {
    if (null == bitmap) {
        if (null != listener) {
            listener.onShare(channel, ShareConstant.SHARE_STATUS_FAILED);
        }
        return;
    }
    if (api.isWXAppInstalled()) {
        if (api.isWXAppSupportAPI()) {
            WXMediaMessage wxMediaMessage = new WXMediaMessage();
            wxMediaMessage.mediaObject = new WXImageObject(bitmap);

            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            while (width * height > THUMB_SIZE * THUMB_SIZE) {
                width /= 2;
                height /= 2;
            }
            Bitmap thumbBmp = Bitmap.createScaledBitmap(bitmap, width, height, true);
            try {
                ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
                thumbBmp.compress(Bitmap.CompressFormat.JPEG, 85, localByteArrayOutputStream);
                wxMediaMessage.thumbData = localByteArrayOutputStream.toByteArray();
                localByteArrayOutputStream.close();
            } catch (Exception e) {

            }

            SendMessageToWX.Req req = new SendMessageToWX.Req();
            req.transaction = String.valueOf(System.currentTimeMillis());
            req.message = wxMediaMessage;
            if (ShareConstant.SHARE_CHANNEL_WEIXIN_FRIEND == channel) {
                req.scene = SendMessageToWX.Req.WXSceneSession;
            } else if (ShareConstant.SHARE_CHANNEL_WEIXIN_CIRCLE == channel) {
                req.scene = SendMessageToWX.Req.WXSceneTimeline;
            }
            api.sendReq(req);
        }
    } else {
        if (null != listener) {
            listener.onShare(channel, ShareConstant.SHARE_STATUS_FAILED);
        }
        ToastUtil.showToast(context, R.string.share_no_weixin_client, true);
    }
}
 
开发者ID:xyzlf,项目名称:ShareSDK,代码行数:46,代码来源:ShareByWeixin.java


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