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


Java IWXAPI.sendReq方法代码示例

本文整理汇总了Java中com.tencent.mm.sdk.openapi.IWXAPI.sendReq方法的典型用法代码示例。如果您正苦于以下问题:Java IWXAPI.sendReq方法的具体用法?Java IWXAPI.sendReq怎么用?Java IWXAPI.sendReq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tencent.mm.sdk.openapi.IWXAPI的用法示例。


在下文中一共展示了IWXAPI.sendReq方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
public void login(Callback callback) {
    IWXAPI iwxapi = init();
    if (iwxapi == null) {
        if (callback != null)
            callback.onFailed();
        return;
    }
    // 唤起微信登录授权
    SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo";
    req.state = "wechat_login";
    // 失败回调
    if (!iwxapi.sendReq(req) && callback != null) {
        callback.onFailed();
    } else {
        if (callback != null)
            callback.onSuccess();
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:20,代码来源:OpenBuilder.java

示例2: shareToWechat

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的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: login

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
@Override
public void login(final Activity activity, Bundle pararms, final LoginCallback callback) {
	DebugLog.d(TAG, "login()");
	
	this.callback = callback;
	
	IWXAPI wxapi = MyApp.getApp().getWXAPI();
	if (!wxapi.isWXAppInstalled()) {
           //提醒用户没有安装微信
		String uninstalled = activity.getResources().getString(R.string.WeixinLogin_uninstalled);
		CustomToast.makeText(activity,uninstalled, 2000).show();
           return;
       }
	
	 SendAuth.Req req = new SendAuth.Req();
     req.scope = "snsapi_userinfo";
     req.state = "wechat_sdk_demo";
     wxapi.sendReq(req);
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:20,代码来源:WeixinLogin.java

示例4: shareToWX

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的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

示例5: onWechatLogin

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
/**
 * 微信授权登录
 */
@Click(R.id.llWechatLogin)
void onWechatLogin() {
  /*  Log.i("LoginActivity", "微信授权登录");
    //AbToastUtil.showToast(mContext,"功能正在完善开发中...");
    Config.dialog = ProgressDialog.show(mContext, "提示", "正在请求跳转....");
    SHARE_MEDIA platform = SHARE_MEDIA.WEIXIN;
    umShareAPI = UMShareAPI.get(mContext);
    umShareAPI.doOauthVerify(this, platform, umAuthListener);*/
    if (Contact.isWeixinAvilible(this)) {
        progressDialog = AbDialogUtil.showProgressDialog(mContext, Global.LOADING_PROGRESSBAR_ID, "登录中");
        mLlWechatLogin.setEnabled(false);
        IWXAPI api = WXAPIFactory.createWXAPI(this, "wx747d053fa471eb15", true);

        api.registerApp("wx747d053fa471eb15");
        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "wechat_sdk_demo_test";
        api.sendReq(req);
    } else {
        ToastUtils.show(this, "请安装微信");
    }
}
 
开发者ID:bangqu,项目名称:eshow-android,代码行数:26,代码来源:LoginActivity.java

示例6: sendPayRequestByWechat

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
private void sendPayRequestByWechat(PayInfo payInfo) {
    if(payInfo == null) {
        return;
    }

    IWXAPI api = WXAPIFactory.createWXAPI(mContext, payInfo.getAppId());
    PayReq payReq = new PayReq();
    payReq.appId = payInfo.getAppId();
    payReq.partnerId = payInfo.getPartnerId();
    payReq.prepayId = payInfo.getPrepayId();
    payReq.nonceStr = payInfo.getNonceStr();
    payReq.timeStamp = payInfo.getTimeStamp();
    payReq.packageValue = payInfo.getPackageValue();
    payReq.sign = payInfo.getSign();
    api.sendReq(payReq);
}
 
开发者ID:g977284333,项目名称:KwPresent,代码行数:17,代码来源:PayManager.java

示例7: share

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的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

示例8: shareToWechat

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
private void shareToWechat(boolean isWechatMoments,boolean isWechat, boolean isWechatFavorite, String imagePath, String comment) {
	IWXAPI api = WXAPIFactory.createWXAPI(MyApp.getInstance(), MyApp.WEIXIN_KEY);
	// 将该app注册到微信
       api.registerApp( MyApp.WEIXIN_KEY);
	WXImageObject imgObj = new WXImageObject();
	imgObj.setImagePath(imagePath);
	
	WXMediaMessage msg = new WXMediaMessage();
	msg.description = comment;
	msg.mediaObject = imgObj;
	
	Bitmap bmp = BitmapFactory.decodeFile(imagePath);
	Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 100, 100, true);
	bmp.recycle();
	msg.thumbData = bmpToByteArray(thumbBmp, true);
	int imageSize = msg.thumbData.length / 1024;
       if (imageSize > 32) {
               Toast.makeText(MyApp.getInstance(), "您分享的图片过大", Toast.LENGTH_SHORT)
                               .show();
               return;
       }
	SendMessageToWX.Req req = new SendMessageToWX.Req();
	req.transaction = buildTransaction("img");
	req.message = msg;
	req.scene = isWechat? SendMessageToWX.Req.WXSceneSession:SendMessageToWX.Req.WXSceneTimeline;
	api.sendReq(req);
	finish();
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:29,代码来源:OnekeyShare.java

示例9: sendToWeiXin

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的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

示例10: sendToCircle

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的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

示例11: onStart

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
@Override
protected void onStart() {
    if (App.getWechatAppId() == null) {
        dispatchException();
        return;
    }
    IWXAPI api = WXAPIFactory.createWXAPI(mContext, mAppId);
    if (api == null) {
        dispatchException();
        return;
    }
    if (!api.isWXAppInstalled()) {
        dispatchException();
        return;
    }
    if (api.getWXAppSupportAPI() < Build.PAY_SUPPORTED_SDK_INT) {
        dispatchException();
        return;
    }
    api.registerApp(mAppId);
    PayReq req = new PayReq();
    req.appId = mAppId;
    req.partnerId = mPartnerId;
    req.prepayId = mPrepayId;
    req.nonceStr = mNonceStr;
    req.timeStamp = mTimeStamp;
    req.packageValue = mPackageValue;
    req.sign = mSign;
    if (mExtData != null) {
        req.extData = mExtData;
    }
    api.sendReq(req);
    WXPayBroadcast broadcast = new WXPayBroadcast(mContext);
    broadcast.setOnReceiveListener(new WXPayBroadcastReceiverListener());
    if (mContext instanceof IStoppableManager) {
        ((IStoppableManager) mContext).bind(this);
    }
    broadcast.start();
}
 
开发者ID:wavinsun,项目名称:MUtils,代码行数:40,代码来源:WXPayTask.java

示例12: onShareToWX

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
public void onShareToWX(View v){
 	FmeiClient client = FmeiClient.getInstance(null);
 	IWXAPI api = WXAPIFactory.createWXAPI(getActivity(), com.emop.client.wxapi.Constants.APP_ID, 
	false);
 	
 	if(api.isWXAppInstalled() && api.isWXAppSupportAPI()){
  	String trackId = "0";
  	if(client.trackUserId != null && client.trackUserId.trim().length() > 0){
  		trackId = client.trackUserId;
  	}
	
String imageURL = String.format(Constants.WEB_SHOP_LINK, trackId, shopId, shortKey);

try{
	WXWebpageObject webObj = new WXWebpageObject(imageURL);
	
	WXMediaMessage msg = new WXMediaMessage();
	msg.mediaObject = webObj;
	msg.title = "推荐你一个好店";
	msg.description = title;
				
	msg.thumbData = getThumbData();
	
	SendMessageToWX.Req req = new SendMessageToWX.Req();
	req.transaction = buildTransaction("img");
	req.message = msg;
	api.sendReq(req);
	Log.i(Constants.TAG_EMOP, "sendReq");
	
} catch(Exception e) {
	e.printStackTrace();
}
 	}else {
 		showToast("没有安装微信应用,不能分享到朋友圈.");
 	}
 }
 
开发者ID:emop,项目名称:EmopAndroid,代码行数:37,代码来源:ItemActionBar.java

示例13: shareToWXFriends

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
/**
 * 分享到微信朋友圈
 * @param context
 * @param title
 * @param url
 */
public static void shareToWXFriends(Activity context,String title,String url){
	IWXAPI api = WXAPIFactory.createWXAPI(context,APP_ID,true);
    api.registerApp(APP_ID);
	// 检查是否安装微信
    if(!api.isWXAppInstalled()) {
    	UIHelper.ToastMessage(context, "抱歉,您尚未安装微信客户端,无法进行微信分享!");
    	return;
    }
    // 检查是否支持
    if(api.getWXAppSupportAPI() < MIN_SUPPORTED_VERSION) {
    	UIHelper.ToastMessage(context, "抱歉,您的微信版本不支持分享到朋友圈!");
    	return;
    }
    WXWebpageObject webpage = new WXWebpageObject();
	webpage.webpageUrl = url;
	WXMediaMessage msg = new WXMediaMessage(webpage);
	msg.title = title;
	msg.description = "分享地址:" + url;
	// 缩略图的二进制数据
	Bitmap thumb = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
	msg.thumbData = bmpToByteArray(thumb, true);
	SendMessageToWX.Req req = new SendMessageToWX.Req();
	// 分享的时间
	req.transaction = String.valueOf(System.currentTimeMillis());
	req.message = msg;
	req.scene = SendMessageToWX.Req.WXSceneTimeline;
	api.sendReq(req);
}
 
开发者ID:WallaceLiu,项目名称:oschina-android-app,代码行数:35,代码来源:WXFriendsHelper.java

示例14: onClick

import com.tencent.mm.sdk.openapi.IWXAPI; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.tvRight:
            Jump(RegisterActivity.class);
            break;
        case R.id.tvForget:
            Jump(ForgetActivity.class);
            break;
        case R.id.btnLogin:

            if (StringUtils.isEmpty(etName.getText().toString())){
                ToastUtils.show(LoginActivity.this,"请输入用户名");
                return;
            }

            if (StringUtils.isEmpty(etPwd.getText().toString())){
                ToastUtils.show(LoginActivity.this,"请输入密码");
                return;
            }

            params=new RequestParams();
            params.put("user.username",etName.getText().toString());
            params.put("user.password",etPwd.getText().toString());
            params.put("user.clientId", Contact.deviceToken);
            post("user/login",params);

            break;
        case R.id.tvWechat:
            if (Contact.isWeixinAvilible(this)) {
                //微信登录发起
                IWXAPI api = WXAPIFactory.createWXAPI(this, "wxce3287b52eccea84", true);

                api.registerApp("wxce3287b52eccea84");
                SendAuth.Req req = new SendAuth.Req();
                req.scope = "snsapi_userinfo";
                req.state = "wechat_sdk_demo_test";
                api.sendReq(req);
            } else {
                ToastUtils.show(this, "请安装微信");
            }
            break;
        case R.id.tvQQ:
            LoginQQ();
            break;
        case R.id.tvShort:
            Jump(CodeLoginActivity.class);
            break;
    }
}
 
开发者ID:bangqu,项目名称:eshow-android,代码行数:51,代码来源:LoginActivity.java


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