當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。