本文整理匯總了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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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, "請安裝微信");
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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("沒有安裝微信應用,不能分享到朋友圈.");
}
}
示例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);
}
示例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;
}
}