本文整理汇总了Java中com.tencent.mm.opensdk.modelmsg.WXWebpageObject类的典型用法代码示例。如果您正苦于以下问题:Java WXWebpageObject类的具体用法?Java WXWebpageObject怎么用?Java WXWebpageObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WXWebpageObject类属于com.tencent.mm.opensdk.modelmsg包,在下文中一共展示了WXWebpageObject类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shareToWX
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的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
示例2: shareWeb
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的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
示例3: shareWeb
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
@Override
public void shareWeb(final int shareTarget, Activity activity, final ShareObj obj) {
BitmapUtils.getStaticSizeBitmapByteByPathTask(obj.getThumbImagePath(), THUMB_IMAGE_SIZE)
.continueWith(new ThumbDataContinuation(TAG, "shareWeb", mOnShareListener) {
@Override
public void onSuccess(byte[] thumbData) {
WXWebpageObject webPage = new WXWebpageObject();
webPage.webpageUrl = obj.getTargetUrl();
WXMediaMessage msg = new WXMediaMessage(webPage);
msg.title = obj.getTitle();
msg.description = obj.getSummary();
msg.thumbData = thumbData;
sendMsgToWx(msg, shareTarget, "web");
}
}, Task.UI_THREAD_EXECUTOR);
}
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:18,代码来源:WxPlatform.java
示例4: shareURL
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的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
示例5: shareWebPage
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的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
示例6: shareUrl
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
public static void shareUrl(String url, String title, String description, Bitmap author, boolean toTimeline) {
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = new WXWebpageObject(url);
msg.title = title;
msg.description = description;
if (author != null && !author.isRecycled()) {
msg.thumbData = bitmap2Bytes(author);
}
sendRequest2Wechat(msg, toTimeline);
}
开发者ID:ChaosLeong,项目名称:FxcnBeta,代码行数:12,代码来源:WXApiProvider.java
示例7: shareMedia
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; //导入依赖的package包/类
@Override
public void shareMedia(
final int platform, final String title, final String targetUrl, final String summary,
final ShareImageObject shareImageObject, final Activity activity, final ShareListener listener) {
Flowable.create(new FlowableOnSubscribe<byte[]>() {
@Override
public void subscribe(@NonNull FlowableEmitter<byte[]> emitter) throws Exception {
try {
String imagePath = ImageDecoder.decode(activity, shareImageObject);
emitter.onNext(ImageDecoder.compress2Byte(imagePath, TARGET_SIZE, THUMB_SIZE));
} catch (Exception e) {
emitter.onError(e);
}
}
}, BackpressureStrategy.DROP)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnRequest(new LongConsumer() {
@Override
public void accept(long aLong) {
listener.shareRequest();
}
})
.subscribe(new Consumer<byte[]>() {
@Override
public void accept(byte[] bytes) {
WXWebpageObject webpageObject = new WXWebpageObject();
webpageObject.webpageUrl = targetUrl;
WXMediaMessage message = new WXMediaMessage(webpageObject);
message.title = title;
message.description = summary;
message.thumbData = bytes;
sendMessage(platform, message, buildTransaction("webPage"));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
activity.finish();
listener.shareFailure(new Exception(throwable));
}
});
}
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:45,代码来源:WxShareInstance.java
注:本文中的com.tencent.mm.opensdk.modelmsg.WXWebpageObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论