com.tencent.mm.sdk.openapi.WXAPIFactory Java Examples

The following examples show how to use com.tencent.mm.sdk.openapi.WXAPIFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 6 votes vote down vote up
public SharePopWindow(Context context) {
	this.context = context;
	collectDAO = new CollectDAO(context);
	api = WXAPIFactory.createWXAPI(context, com.lling.qiqu.wxapi.Constants.APP_ID);
	LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.popup_share, null);
    view.findViewById(R.id.share_weixin).setOnClickListener(this);
    view.findViewById(R.id.share_pengyouquan).setOnClickListener(this);
    view.findViewById(R.id.share_qqfriends).setOnClickListener(this);
    view.findViewById(R.id.share_qqzone).setOnClickListener(this);
    view.findViewById(R.id.share_qqweibo).setOnClickListener(this);
    view.findViewById(R.id.share_sinaweibo).setOnClickListener(this);
    view.findViewById(R.id.share_sms).setOnClickListener(this);
    view.findViewById(R.id.share_copy).setOnClickListener(this);
    view.findViewById(R.id.share_collect).setOnClickListener(this);
	initWindow();
	this.setContentView(view);
}
 
Example #2
Source File: Utils.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public static boolean isWeixinSupportJump(Context context)
{
    if (WXAPIFactory.createWXAPI(context, "wx28e2610e92fbe111").isWXAppInstalled())
    {
        int j;
        try
        {
            j = context.getPackageManager().getPackageInfo("com.tencent.mm", 0).versionCode;
        }
        catch (android.content.pm.PackageManager.NameNotFoundException namenotfoundexception)
        {
            return false;
        }
        if (j >= 480)
        {
            return true;
        }
    }
    return false;
}
 
Example #3
Source File: BindWeixinActivityNew.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
protected void onCreate(Bundle bundle)
{
    super.onCreate(bundle);
    setContentView(0x7f030001);
    e = (Button)findViewById(0x7f0a0028);
    e.setOnClickListener(this);
    h = findViewById(0x7f0a002a);
    f = (TextView)findViewById(0x7f0a002b);
    f.setOnClickListener(this);
    i = findViewById(0x7f0a002c);
    j = (ImageView)findViewById(0x7f0a002d);
    k = (TextView)findViewById(0x7f0a002f);
    g = new E(this);
    EventBus.getDefault().register(this, "onBleStatusChanged", cn/com/smartdevices/bracelet/ui/BaseSCActivity$ConnStatus, new Class[0]);
    l = WXAPIFactory.createWXAPI(this, "wx28e2610e92fbe111");
    l.registerApp("wx28e2610e92fbe111");
}
 
Example #4
Source File: BindWeixinActivity.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a()
{
    IWXAPI iwxapi = WXAPIFactory.createWXAPI(this, "wx28e2610e92fbe111");
    iwxapi.registerApp("wx28e2610e92fbe111");
    if (iwxapi.isWXAppInstalled())
    {
        iwxapi.openWXApp();
    }
}
 
Example #5
Source File: Activity_Result.java    From MortgageCalculator with Apache License 2.0 5 votes vote down vote up
public void init(){
    //微信分享初始化
    wxApi = WXAPIFactory.createWXAPI(this, WXAppID);
    wxApi.registerApp(WXAppID);

    //有米
    //获取要嵌入广告条的布局
    LinearLayout bannerLayout = (LinearLayout)findViewById(R.id.ll_banner1);

    //获取广告条
    View bannerView = BannerManager.getInstance(Activity_Result.this).getBannerView(new net.youmi.android.normal.banner.BannerViewListener() {
        @Override
        public void onRequestSuccess() {
            System.out.println("请求广告成功");
        }

        @Override
        public void onSwitchBanner() {
            System.out.println("切换广告条");
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.addRule(RelativeLayout.ABOVE,  R.id.ll_banner1);
            lp.addRule(RelativeLayout.BELOW, R.id.ResultCursorImageView);
            viewPager.setLayoutParams(lp);
        }

        @Override
        public void onRequestFailed() {
            System.out.println("请求广告失败");
        }
    });

    //将广告条加入到布局中
    bannerLayout.addView(bannerView);
}
 
Example #6
Source File: Activity_Result_Combination.java    From MortgageCalculator with Apache License 2.0 5 votes vote down vote up
public void init(){
    //微信分享初始化
    wxApi = WXAPIFactory.createWXAPI(this, WXAppID);
    wxApi.registerApp(WXAppID);

    //有米
    //获取要嵌入广告条的布局
    LinearLayout bannerLayout = (LinearLayout)findViewById(R.id.ll_banner2);

    //获取广告条
    View bannerView = BannerManager.getInstance(Activity_Result_Combination.this).getBannerView(new net.youmi.android.normal.banner.BannerViewListener() {
        @Override
        public void onRequestSuccess() {
            System.out.println("请求广告成功");
        }

        @Override
        public void onSwitchBanner() {
            System.out.println("切换广告条");
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.addRule(RelativeLayout.ABOVE,  R.id.ll_banner2);
            lp.addRule(RelativeLayout.BELOW, R.id.Result_Combination_Cursor_ImageView);
            viewPager.setLayoutParams(lp);
        }

        @Override
        public void onRequestFailed() {
            System.out.println("请求广告失败");
        }
    });

    //将广告条加入到布局中
    bannerLayout.addView(bannerView);
}
 
Example #7
Source File: WXEntryActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	IWXAPI api = WXAPIFactory.createWXAPI(this, GosDeploy.setWechatAppID(),
			true);
	api.handleIntent(getIntent(), this);
}
 
Example #8
Source File: SharePanelView.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public static IWXAPI getIWXAPI(){
    if(iwxapi == null){
        iwxapi = WXAPIFactory.createWXAPI(MyApp.getInstance().getApplicationContext(),WECHAT_APP_ID,true);
        iwxapi.registerApp(WECHAT_APP_ID);
    }
    return iwxapi;
}
 
Example #9
Source File: WXEntryActivity.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_wxentry);
	// 通过WXAPIFactory工厂,获取IWXAPI的实例
   	api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, false);
   	api.handleIntent(getIntent(), this);
}
 
Example #10
Source File: WeixinHelper.java    From android-common-utils with Apache License 2.0 5 votes vote down vote up
public WeixinHelper initWXApi(Context context){
   // if(mWxApi !=null)  return this;
    mWxApi = WXAPIFactory.createWXAPI(context.getApplicationContext(),
            SdkFactory.ShareConfig.sWeixin_app_Id, false);
    mWxApi.registerApp(SdkFactory.ShareConfig.sWeixin_app_Id);
    return this;
}
 
Example #11
Source File: WeixinPayHelper.java    From android-common-utils with Apache License 2.0 5 votes vote down vote up
public WeixinPayHelper initWXPayApi(Context context) {
    //支付。对应的activity 需要配置scheme  SdkConfig.WEIXIN_PAY_APP_ID
    mWxApi = WXAPIFactory.createWXAPI(context.getApplicationContext(),
            SdkFactory.PayConfig.sWeixin_app_Id, false);
    mWxApi.registerApp(SdkFactory.PayConfig.sWeixin_app_Id);
    return this;
}
 
Example #12
Source File: WXEntryActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
  	Log.i(TAG, "onCreate");
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_wechat_login_dialog);
  	api = WXAPIFactory.createWXAPI(this, Constants.WECHAT_APPID, false);
  	api.registerApp(Constants.WECHAT_APPID);    	
      api.handleIntent(getIntent(), this);
      it=getIntent();
      int type=0;
      if(it!=null){
      	type=it.getIntExtra(TYPE, 0);
      }
      if(type==LOGIN){
      	SendAuth.Req req = new SendAuth.Req();
      	req.scope = "snsapi_userinfo";
      	req.state = state=Long.toString(System.currentTimeMillis());
      	api.sendReq(req);
      }
      findViewById(R.id.wechat_close).setOnClickListener(new View.OnClickListener() {
	
	@Override
	public void onClick(View v) {
		finish();
	}
});
  }
 
Example #13
Source File: SendToWXActivity.java    From wechatsdk-xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
	
	setContentView(R.layout.send_to_wx);
	initView();
}
 
Example #14
Source File: GetFromWXActivity.java    From wechatsdk-xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// acquire wxapi
	api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
	bundle = getIntent().getExtras();

	setContentView(R.layout.get_from_wx);
	initView();
}
 
Example #15
Source File: AppRegister.java    From wechatsdk-xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
	final IWXAPI api = WXAPIFactory.createWXAPI(context, null);

	// ����appע�ᵽ΢��
	api.registerApp(Constants.APP_ID);
}
 
Example #16
Source File: TestSendToWXActivity.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	Context fakeContext = FakeUtil.fakeContext(this);
	api = WXAPIFactory.createWXAPI(fakeContext, WXEntryActivity.APP_ID, false);
	api.registerApp(WXEntryActivity.APP_ID);

	setContentView(R.layout.send_activity);


	ILoginService login = (ILoginService) getSystemService("login_service");
	if (login != null) {
		LoginVO vo = login.login("admin", "123456");
		Toast.makeText(this, vo.getUsername() + ":" + vo.getPassword(), Toast.LENGTH_SHORT).show();
	} else {
		Toast.makeText(this, "ILoginService == null", Toast.LENGTH_SHORT).show();
	}

	findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			WXTextObject textObj = new WXTextObject();
			textObj.text = "呵呵更健康";

			WXMediaMessage msg = new WXMediaMessage();
			msg.mediaObject = textObj;
			msg.title = "Will be ignored";
			msg.description = "呵呵更健康";

			SendMessageToWX.Req req = new SendMessageToWX.Req();
			req.transaction = "呵呵更健康" + String.valueOf(System.currentTimeMillis());
			req.message = msg;
			req.scene = SendMessageToWX.Req.WXSceneSession;//发送给某人

			api.sendReq(req);
		}
	});
}
 
Example #17
Source File: WeChat.java    From ESSocialSDK with Apache License 2.0 5 votes vote down vote up
public static IWXAPI getIWXAPIInstance(Context context, String appId) {
    if (null == api) {
        api = WXAPIFactory.createWXAPI(context, appId, true);
        api.registerApp(appId);
    }

    return api;
}
 
Example #18
Source File: MainActivity.java    From Example-of-Cocos2DX with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	Log.d("sss","Main create");
	
	api = WXAPIFactory.createWXAPI(this, APP_ID,true);
	api.registerApp(APP_ID);
	s_Instance = this;
}
 
Example #19
Source File: RLWeixinHelper.java    From Roid-Library with Apache License 2.0 5 votes vote down vote up
private RLWeixinHelper(Context context) {
    if (api == null) {
        String key = context.getString(R.string.weixin_key);
        api = WXAPIFactory.createWXAPI(context, key, false);
        api.registerApp(key);
    }
}
 
Example #20
Source File: Activity_Result.java    From MortgageCalculator with Apache License 2.0 5 votes vote down vote up
public void init(){
    //微信分享初始化
    wxApi = WXAPIFactory.createWXAPI(this, WXAppID);
    wxApi.registerApp(WXAppID);

    /*//有米
    //获取要嵌入广告条的布局
    LinearLayout bannerLayout = (LinearLayout)findViewById(R.id.ll_banner1);

    //获取广告条
    View bannerView = BannerManager.getInstance(Activity_Result.this).getBannerView(new net.youmi.android.normal.banner.BannerViewListener() {
        @Override
        public void onRequestSuccess() {
            System.out.println("请求广告成功");
        }

        @Override
        public void onSwitchBanner() {
            System.out.println("切换广告条");
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.addRule(RelativeLayout.ABOVE,  R.id.ll_banner1);
            lp.addRule(RelativeLayout.BELOW, R.id.ResultCursorImageView);
            viewPager.setLayoutParams(lp);
        }

        @Override
        public void onRequestFailed() {
            System.out.println("请求广告失败");
        }
    });

    //将广告条加入到布局中
    bannerLayout.addView(bannerView);*/
}
 
Example #21
Source File: Activity_Result_Combination.java    From MortgageCalculator with Apache License 2.0 5 votes vote down vote up
public void init(){
    //微信分享初始化
    wxApi = WXAPIFactory.createWXAPI(this, WXAppID);
    wxApi.registerApp(WXAppID);

    /*//有米
    //获取要嵌入广告条的布局
    LinearLayout bannerLayout = (LinearLayout)findViewById(R.id.ll_banner2);

    //获取广告条
    View bannerView = BannerManager.getInstance(Activity_Result.this).getBannerView(new net.youmi.android.normal.banner.BannerViewListener() {
        @Override
        public void onRequestSuccess() {
            System.out.println("请求广告成功");
        }

        @Override
        public void onSwitchBanner() {
            System.out.println("切换广告条");
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.addRule(RelativeLayout.ABOVE,  R.id.ll_banner1);
            lp.addRule(RelativeLayout.BELOW, R.id.ResultCursorImageView);
            viewPager.setLayoutParams(lp);
        }

        @Override
        public void onRequestFailed() {
            System.out.println("请求广告失败");
        }
    });

    //将广告条加入到布局中
    bannerLayout.addView(bannerView);*/
}
 
Example #22
Source File: OnekeyShare.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #23
Source File: WeixinShareApi.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
private static void doShareWebPage(final String url,final String title,final String desc,final String img,final boolean timelined) {
    if(api==null) {
        api= WXAPIFactory.createWXAPI(MainApp.getContext(), APP_ID);
    }

    Bitmap bitmap= ImageUtil.getBitmap(img);
    Bitmap thumb =null;
    if(bitmap!=null){
        thumb=Bitmap.createScaledBitmap(bitmap, 64, 64, true);
    }

    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = title;
    msg.description = desc;

    if(thumb!=null) {
        msg.thumbData = BitmapUtil.bmpToByteArray(thumb, true);
    }else{
        Bitmap thumbIcon = BitmapFactory.decodeResource(MainApp.getInstance().getResources(), R.drawable.icon);
        msg.thumbData = BitmapUtil.bmpToByteArray(thumbIcon, true);
    }

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("webpage");
    req.message = msg;
    req.scene = timelined ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
    api.sendReq(req);
}
 
Example #24
Source File: LetvAlipayManager.java    From letv with Apache License 2.0 5 votes vote down vote up
private boolean initWxpayApi(String appId) {
    if (TextUtils.isEmpty(appId)) {
        ToastUtils.showToast(this.activity, this.activity.getString(2131100995));
        return false;
    }
    this.api = WXAPIFactory.createWXAPI(this.activity, appId);
    this.api.registerApp(appId);
    this.isRegisterWx = true;
    return true;
}
 
Example #25
Source File: WXEntryActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(1);
    super.onCreate(savedInstanceState);
    if (this.mLetvApplication == null) {
        this.mLetvApplication = (LetvApplication) getApplicationContext();
    }
    this.mLetvApplication.setWxisShare(true);
    this.api = WXAPIFactory.createWXAPI(this, Weixin.APP_ID, true);
    this.api.handleIntent(getIntent(), this);
}
 
Example #26
Source File: WxLoginInstance.java    From ShareUtil with Apache License 2.0 5 votes vote down vote up
public WxLoginInstance(Activity activity, LoginListener listener, boolean fetchUserInfo) {
    super(activity, listener, fetchUserInfo);
    mLoginListener = listener;
    mIWXAPI = WXAPIFactory.createWXAPI(activity, ShareManager.CONFIG.getWxId());
    mClient = new OkHttpClient();
    this.fetchUserInfo = fetchUserInfo;
}
 
Example #27
Source File: WXPayEntryActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(1);
    this.api = WXAPIFactory.createWXAPI(this, LetvAlipayManager.WX_PAY_APP_ID);
    LogInfo.log("weixin", "WXPayEntryActivity appId = " + LetvAlipayManager.WX_PAY_APP_ID);
    this.api.handleIntent(getIntent(), this);
}
 
Example #28
Source File: WXPayEntryActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.wxPay = WXPay.getInstance(this);
    this.api = WXAPIFactory.createWXAPI(this, APP_ID);
    this.api.handleIntent(getIntent(), this);
}
 
Example #29
Source File: WeChatHelper.java    From talk-android with MIT License 4 votes vote down vote up
private WeChatHelper(Context ctx) {
    wxApi = WXAPIFactory.createWXAPI(ctx, APP_ID);
    wxApi.registerApp(APP_ID);
}
 
Example #30
Source File: ThirdPartLoginLayout.java    From letv with Apache License 2.0 4 votes vote down vote up
public void initThirtPart() {
    this.mIWXAPI = WXAPIFactory.createWXAPI(this.mContext, Weixin.APP_ID);
    this.mIWXAPI.registerApp(Weixin.APP_ID);
    this.mTencent = TencentInstance.getInstance(this.mActivity);
    this.mCoolcloud = Coolcloud.get(BaseApplication.getInstance(), LoginConstant.COOLPAD_APP_ID);
}