Ejemplo n.º 1
0
 private void initWeChat() {
   weChatUtils = WeChatUtils.getInstance(this);
   if (weChatUtils.getIWXAPI().isWXAppInstalled()) {
     weChatUtils.register();
     weChatUtils.getIWXAPI().handleIntent(getIntent(), this);
   }
 }
Ejemplo n.º 2
0
  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    setIntent(intent);
    weChatUtils.getIWXAPI().handleIntent(intent, this);
  }
Ejemplo n.º 3
0
  private void sendToWeChat() {
    final String text =
        String.format(getString(R.string.share_text_full_total), appPreference.getTotalNumber());
    ScreenshotUtils.shotBitmap2(this, shareFileName);
    weChatUtils.createAppendReq2(this.getString(R.string.app_name), text, shareFileName);

    Intent intent = new Intent();
    intent.setClass(this, me.pjq.pushup.activity.SendToWXActivity.class);
    startActivity(intent);

    Utils.overridePendingTransitionRight2Left(this);
  }
Ejemplo n.º 4
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (weChatUtils.getIWXAPI().isWXAppInstalled()) {
      inflater.inflate(R.menu.main_wechat, menu);
    } else {
      inflater.inflate(R.menu.main, menu);
    }

    MenuItem shareItem = menu.findItem(R.id.action_share);
    android.support.v4.view.ActionProvider actionProvider =
        MenuItemCompat.getActionProvider(shareItem);
    if (null != actionProvider && actionProvider instanceof ShareActionProvider) {
      mShareActionProvider.setShareHistoryFileName(
          ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
      // mShareActionProvider.setShareIntent(Utils.getShareRawIntent(this));

      mShareActionProvider.setOnShareTargetSelectedListener(
          new ShareActionProvider.OnShareTargetSelectedListener() {
            @Override
            public boolean onShareTargetSelected(
                ShareActionProvider shareActionProvider, Intent intent) {
              updateShareIntent();
              return false;
            }
          });
      updateShareIntent();

      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == R.id.action_share) {
          View itemChooser = MenuItemCompat.getActionView(item);
          if (itemChooser != null) {
            itemChooser.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    EFLogger.i(TAG, "onClick");
                    ScreenshotUtils.shotBitmap(MainActivity.this, shareFileName);
                  }
                });
          }
        }
      }
    }

    return super.onCreateOptionsMenu(menu);
  }