本文整理汇总了Java中com.tencent.mm.opensdk.openapi.WXAPIFactory类的典型用法代码示例。如果您正苦于以下问题:Java WXAPIFactory类的具体用法?Java WXAPIFactory怎么用?Java WXAPIFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WXAPIFactory类属于com.tencent.mm.opensdk.openapi包,在下文中一共展示了WXAPIFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shareToWX
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
/**
* @param flag
* 0 发送到会话
* 1 发送到朋友圈
*/
private int shareToWX(int flag){
String text = mDetailItem.getUserName()+"说: "+mDetailItem.getRantContent()+" " + "\n目前有"+mDetailItem.getCommentList().size()+"人围观,来凑个热闹吧!";
final IWXAPI iwxapi = WXAPIFactory.createWXAPI(this, getString(R.string.app_id));
iwxapi.registerApp(getString(R.string.app_id));
if(!iwxapi.isWXAppInstalled()){
Toast.makeText(this, "你还没有安装微信", Toast.LENGTH_SHORT).show();
return 0;
}
WXWebpageObject webpage = new WXWebpageObject();
webpage.webpageUrl = getString(R.string.ip_server)+"rant.action?rantId="+mDetailItem.getRantId();
final WXMediaMessage msg = new WXMediaMessage(webpage);
msg.title = "Rant社区";
msg.description = text;
final SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = String.valueOf(System.currentTimeMillis());
req.scene = flag;
final Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
msg.setThumbImage(logo);
req.message = msg;
iwxapi.sendReq(req);
return 1;
}
示例2: PayWXStart
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
public PayWXStart(Context mContext, int mOrderId){
context = mContext;
orderId = mOrderId;
aCache = ACache.get(GApplication.getInstance());
loginData = (LoginData) aCache.getAsObject(ACacheKey.CURRENT_ACCOUNT);
api = WXAPIFactory.createWXAPI(context, Constants.APP_ID);
api.registerApp(Constants.APP_ID);
Log.e("aaa", "orderId:" + orderId);
Log.e("aaa", loginData.getToken());
api.registerApp(Constants.APP_ID);
getPayData();
}
示例3: WXBase
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
protected WXBase(Activity activity, Platform platform) {
mActivity = activity;
mPlatform = platform;
if (!TextUtils.isEmpty(platform.getAppId())) {
mApi = WXAPIFactory.createWXAPI(activity.getApplicationContext(), platform.getAppId(), true);
mApi.registerApp(platform.getAppId());
}
services.put(this, true);
}
示例4: onCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_wxentry);
// 通过WXAPIFactory工厂,获取IWXAPI的实例
api = WXAPIFactory.createWXAPI(this, APP_ID, false);
api.handleIntent(getIntent(), this);
}
示例5: onCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, AppConfig.getWeixinAppId(), false);
try {
api.handleIntent(getIntent(), this);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: Wxpay
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
private Wxpay(Activity context) {
this.context = context;
if (mWXApi == null) {
mWXApi = WXAPIFactory.createWXAPI(context, Config.app_id);
mWXApi.registerApp(Config.app_id);
}
}
示例7: onCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pay_result);
api = WXAPIFactory.createWXAPI(this, Constant.APP_ID);
api.handleIntent(getIntent(), this);
EventBus.getDefault().register(this);
}
示例8: onWXEntryActivityOnCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
/**
* 在WXEntryActivity onCreate方法中执行
*/
public static void onWXEntryActivityOnCreate(Activity wXPayEntryActivity, IWXAPIEventHandler iwxapiEventHandler){
api = WXAPIFactory.createWXAPI(wXPayEntryActivity, null);
api.registerApp(AppConstant.APP_ID);
api.handleIntent(wXPayEntryActivity.getIntent(), iwxapiEventHandler);
}
示例9: registerWX
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
private static void registerWX(Context context) {
//
api = WXAPIFactory.createWXAPI(context, AppConstant.APP_ID, true);
api.registerApp(AppConstant.APP_ID);
if (!api.isWXAppInstalled()){
ToastUtil.showShort("您还未安装微信客户端");
}
}
示例10: onReceive
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
//通过工厂模式获取IWXAPI的实例
final IWXAPI api = WXAPIFactory.createWXAPI(context,null);
api.registerApp(AppConstant.APP_ID);
}
示例11: getWXAPI
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
/**
* Get weixin api
* @return wxAPI
*/
public IWXAPI getWXAPI() {
if (wxAPI == null && !APP_ID.isEmpty()) {
wxAPI = WXAPIFactory.createWXAPI(mContext, APP_ID, true);
}
return wxAPI;
}
示例12: getWXAPIWithContext
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
public static IWXAPI getWXAPIWithContext(Context ctx) {
if (wxAPI == null && !APP_ID.isEmpty()) {
wxAPI = WXAPIFactory.createWXAPI(ctx, APP_ID, true);
}
return wxAPI;
}
示例13: onCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.pay_results);
// appid需换成商户自己开放平台appid
api = WXAPIFactory.createWXAPI(this, JrmfClient.getWxAppId());
api.handleIntent(getIntent(), this);
}
示例14: onCreate
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pay_wx_result);
api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
api.handleIntent(getIntent(), this);
}
示例15: initData
import com.tencent.mm.opensdk.openapi.WXAPIFactory; //导入依赖的package包/类
@Override
protected void initData() {
instance = this;
context = this;
api = WXAPIFactory.createWXAPI(this, APP_ID, true);
api.registerApp(APP_ID);
final SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "wechat_sdk_demo_test";
api.sendReq(req);
}