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


Java IWXAPI类代码示例

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


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

import com.tencent.mm.sdk.openapi.IWXAPI; //导入依赖的package包/类
private synchronized IWXAPI getIwxapiInstance() {
    if (iwxapi == null && mPayModel != null) {
        MPayWeChatModel mPayWeChatModel = (MPayWeChatModel) mPayModel;
        if (mPayWeChatModel != null
                && mPayWeChatModel.getAppId() != null
                && !mPayWeChatModel.getAppId().equals("")
                ) {
            iwxapi = WXAPIFactory.createWXAPI(context, mPayWeChatModel.getAppId());
            MPayConfig.WE_CHAT_PAY_APP_ID = mPayWeChatModel.getAppId();
        }
    }
    if (iwxapi == null) {
        Log.e(TAG, "iwxapi is null ! iwxapi instance is failure !");
    }
    return iwxapi;
}
 
开发者ID:MrxMo,项目名称:MPay,代码行数:17,代码来源:MPayWeChat.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: getWxApi

import com.tencent.mm.sdk.openapi.IWXAPI; //导入依赖的package包/类
private static IWXAPI getWxApi() {
	if (sWxApi == null) {
		sWxApi = WXAPIFactory.createWXAPI(App.get(), Const.ThirdAccount.WECHAT_APP_ID, !Debug.DEBUG);	//第三个参数表示是否检查签名
		sWxApi.registerApp(Const.ThirdAccount.WECHAT_APP_ID);
	}
	return sWxApi;
}
 
开发者ID:isuhao,项目名称:QMark,代码行数:8,代码来源:WeChat.java

示例10: onNewIntent

import com.tencent.mm.sdk.openapi.IWXAPI; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    setIntent(intent);
    IWXAPI api = WeChat.getIWXAPIInstance();
    if (null != api)
        api.handleIntent(intent, this);
}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:10,代码来源:WXCallbackActivity.java

示例11: getIWXAPIInstance

import com.tencent.mm.sdk.openapi.IWXAPI; //导入依赖的package包/类
public static IWXAPI getIWXAPIInstance(Context context, String appId) {
    if (null == api) {
        api = WXAPIFactory.createWXAPI(context, appId, true);
        api.registerApp(appId);
    }

    return api;
}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:9,代码来源:WeChat.java

示例12: 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

示例13: isInstalled

import com.tencent.mm.sdk.openapi.IWXAPI; //导入依赖的package包/类
public static boolean isInstalled(Context context, int type) {
    if (context == null)
        return false;
    IWXAPI api = WXAPIFactory.createWXAPI(context, BuildConfig.WECHAT_APP_ID, false);
    api.registerApp(BuildConfig.WECHAT_APP_ID);
    return api.isWXAppInstalled();
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:8,代码来源:ShareWechat.java

示例14: 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

示例15: 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


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