本文整理汇总了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);
}