本文整理匯總了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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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, "請安裝微信");
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}