@Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    setIntent(intent);
    api.handleIntent(intent, this);
  }
Beispiel #2
0
  @Override
  public void onReceive(Context context, Intent intent) {
    final IWXAPI api = WXAPIFactory.createWXAPI(context, null);

    // 将该app注册到微信
    api.registerApp(Constants.APP_ID);
  }
Beispiel #3
0
  public static void shareWechat(Context context, String text) {
    IWXAPI api = getWechatApi(context);
    api.registerApp(Constants.APP_ID);
    int wxSdkVersion = api.getWXAppSupportAPI();
    if (wxSdkVersion < TIMELINE_SUPPORTED_VERSION) {
      return;
    }

    if (text == null || text.length() == 0) {
      return;
    }

    // 初始化一个WXTextObject对象
    WXTextObject textObj = new WXTextObject();
    textObj.text = text;

    // 用WXTextObject对象初始化一个WXMediaMessage对象
    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = textObj;
    // 发送文本类型的消息时,title字段不起作用
    // msg.title = "Will be ignored";
    msg.description = text;

    // 构造一个Req
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
    req.message = msg;
    req.scene = SendMessageToWX.Req.WXSceneTimeline;

    // 调用api接口发送数据到微信
    api.sendReq(req);
  }
Beispiel #4
0
  public static void shareWechatUrl(
      Context context, boolean isTimeLine, String url, String title, String dsc, Bitmap thumb) {
    IWXAPI api = getWechatApi(context);
    api.registerApp(Constants.APP_ID);

    //        WXTextObject textObj = new WXTextObject();
    //        textObj.text = text;

    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = title;
    msg.description = dsc;
    if (thumb != null) {
      msg.thumbData = Util.bmpToByteArray(thumb, true);
    }
    //        msg.mediaObject = textObj;

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("webpage");
    req.message = msg;
    req.scene =
        isTimeLine ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
    api.sendReq(req);
  }
  private void weixinPay() {
    String packge = "Sign=WXPay";
    api = WXAPIFactory.createWXAPI(this, WeixinConstants.APP_ID, true);
    req.appId = app_id;
    req.nonceStr = nonce_str;
    req.packageValue = packge;
    req.partnerId = mch_id;
    req.prepayId = prepay_id;
    req.timeStamp = timeStamp;

    List<NameValuePair> signParams = new LinkedList<NameValuePair>();
    signParams.add(new BasicNameValuePair("appid", req.appId));
    signParams.add(new BasicNameValuePair("noncestr", req.nonceStr));
    signParams.add(new BasicNameValuePair("package", req.packageValue));
    signParams.add(new BasicNameValuePair("partnerid", req.partnerId));
    signParams.add(new BasicNameValuePair("prepayid", req.prepayId));
    // signParams.add(new BasicNameValuePair("sign", sign));
    signParams.add(new BasicNameValuePair("timestamp", req.timeStamp));
    req.sign = genAppSign(signParams);
    if (dialog.isShowing()) {
      dialog.dismiss();
    }
    api.registerApp(WeixinConstants.APP_ID);
    api.sendReq(req);
    bt_pay.setEnabled(true);
  }
Beispiel #6
0
  public boolean isUsableWX(Context context) {
    boolean isUsable = true;
    api = WXAPIFactory.createWXAPI(context, APP_WX_ID);
    api.registerApp(APP_WX_ID);
    if (api.isWXAppInstalled()) {}

    return isUsable;
  }
Beispiel #7
0
 public static void WXImageShare(Context context, WXMediaMessage msg) {
   api = WXAPIFactory.createWXAPI(context, APP_WX_ID);
   api.registerApp(APP_WX_ID);
   if (api.isWXAppInstalled()) {
     SendMessageToWX.Req req = new SendMessageToWX.Req();
     req.transaction = buildTransaction("img");
     req.message = msg;
     req.scene = SendMessageToWX.Req.WXSceneSession;
     api.sendReq(req);
   } else {
     Toast.makeText(context, "您没有安装微信客户端,无法使用该功能!", Toast.LENGTH_LONG).show();
   }
 }
  @Override
  protected void init() throws Exception {
    if (mIWXAPI == null) {
      mIWXAPI = WXAPIFactory.createWXAPI(getContext(), mAppId, true);
      if (mIWXAPI.isWXAppInstalled()) {
        mIWXAPI.registerApp(mAppId);
      }
    }

    if (!mIWXAPI.isWXAppInstalled()) {
      String msg = getContext().getString(R.string.bili_share_sdk_not_install_wechat);
      Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
      throw new ShareException(msg, BiliShareStatusCode.ST_CODE_SHARE_ERROR_NOT_INSTALL);
    }
  }
Beispiel #9
0
  private void callPay(final WxOrderVO order) {
    final IWXAPI wxApi = WXAPIFactory.createWXAPI(ctx, GlobalConsts.WX_ID);
    wxApi.registerApp(GlobalConsts.WX_ID);

    PayReq req = new PayReq();
    req.appId = order.getAppid();
    req.partnerId = order.getPartnerid();
    req.prepayId = order.getPrepayid();
    req.packageValue = order.getPkg();
    req.nonceStr = order.getNoncestr();
    req.timeStamp = order.getTimestamp();
    req.sign = order.getSign();

    wxApi.sendReq(req);
  }
  private void auth(JSONArray params, final CallbackContext callbackContext)
      throws JSONException, MalformedURLException, IOException {
    // 微信登录授权
    // params[0] -- scope
    // params[1] -- state
    // 返回值:0-成功;1-微信未安装;2-发送失败
    // final IWXAPI api = ShareWechatPlugin.api;
    if (!api.isWXAppInstalled()) {
      callbackContext.error(ERR_WECHAT_NOT_INSTALLED);
      return;
    }
    if (params == null) {
      callbackContext.error(ERR_INVALID_OPTIONS);
      return;
    }

    String scope = params.getString(0);
    String state = params.getString(1);

    final SendAuth.Req req = new SendAuth.Req();
    req.scope = scope;
    req.state = state;

    boolean success = api.sendReq(req);
    if (success) {
      // Log.i(TAG, "发送成功.");
      //			System.out.println("授权请求发送成功");
      sendNoResultPluginResult(callbackContext);
    } else {
      //			System.out.println("授权请求发送失败了");
      callbackContext.error(ERR_SENT_FAILED);
    }

    //		currentCallbackContext = callbackContext;
    //		try {
    //            boolean success = api.sendReq(req);
    //            if (!success) {
    //                //callbackContext.error(ERR_SENT_FAILED);
    //                //return;
    //            }else{
    //            	//callbackContext.success(SUCCESS);
    //            }
    //        } catch (Exception e) {
    //            //callbackContext.error(e.getMessage());
    //            return;
    //        }

  }
  @Override
  public void initView() {
    clickLeft_iv(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent =
                new Intent(LineTeachSelePlayActivity.this, LineTeachOrderActivity.class);
            intent.putExtra("TYPE", PLAY_ZH);
            startActivity(intent);
            finish();
          }
        });

    req = new PayReq();
    sb = new StringBuffer();
    msgApi.registerApp(APP_ID);
    /** ************ 微信支付 ************* */
    setTitle(R.string.golfs_marktitle_06);

    /** 获取传递过来的支付对象 * */
    Intent intent = getIntent();
    orderBean = (OrderBean) intent.getSerializableExtra("orderbean");

    // 支付金额
    aQuery.id(R.id.play_mark).text(getString(R.string.golfs_money) + orderBean.goodsAmount);

    /** ** 支付方式 **** */
    zhifuRelativeLayout = (RelativeLayout) findViewById(R.id.zhufu_rel_01);
    zhifuRelativeLayout2 = (RelativeLayout) findViewById(R.id.zhufu_rel_02);
    zhifuRelativeLayout.setOnClickListener(mClickListener);
    zhifuRelativeLayout2.setOnClickListener(mClickListener);
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.pay_result);
   api = WXAPIFactory.createWXAPI(this, WXConstants.APP_ID_APP);
   api.handleIntent(getIntent(), this);
 }
  /**
   * @param type 0:分享到微信好友,1:分享到微信朋友圈
   * @param url 分享链接
   */
  private void senWechatReq(final int type, String url, String title, String des, String img) {
    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    final WXMediaMessage wechatmsg = new WXMediaMessage(webpage);
    wechatmsg.title = title;
    wechatmsg.description = des;
    Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.worklife_ic_launcher);
    wechatmsg.thumbData = bmpToByteArray(thumb, true);
    // ImageLoader.getInstance().loadImage(img,new
    // SimpleImageLoadingListener(){
    // @Override public void onLoadingComplete(String imageUri, View view,
    // Bitmap loadedImage) {
    // super.onLoadingComplete(imageUri, view, loadedImage);
    // if (loadedImage != null) {
    // wechatmsg.thumbData = bmpToByteArray(loadedImage, true);
    // SendMessageToWX.Req req = new SendMessageToWX.Req();
    // req.transaction = buildTransaction("webpage");
    // req.message = wechatmsg;
    // req.scene = type==0 ? SendMessageToWX.Req.WXSceneTimeline :
    // SendMessageToWX.Req.WXSceneSession;
    // api.sendReq(req);
    // }
    // }
    // });

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("webpage");
    req.message = wechatmsg;
    req.scene =
        type == 0 ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
    api.sendReq(req);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.entry);

    // 通过WXAPIFactory工厂,获取IWXAPI的实例
    api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, false);

    payBtn = (Button) findViewById(R.id.goto_pay_btn);
    payBtn.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(WXEntryActivity.this, PayActivity.class));
            finish();
          }
        });

    // debug

    // debug end

    api.handleIntent(getIntent(), this);
  }
 private void isWechatInstalled(CallbackContext callbackContext) {
   if (!api.isWXAppInstalled()) {
     callbackContext.error(ERR_WECHAT_NOT_INSTALLED);
   } else {
     callbackContext.success(SUCCESS);
   }
   currentCallbackContext = callbackContext;
 }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   //        setContentView(R.layout.transparent_layout);
   user = new User();
   api = WXAPIFactory.createWXAPI(this, WeiXinConstants.APP_ID, false);
   api.handleIntent(getIntent(), this);
 }
Beispiel #17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.activity_com);

    api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
    api.handleIntent(getIntent(), this);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_weixin);
   tv = (TextView) findViewById(R.id.wx_res);
   // 通过WXAPIFactory工厂,获取IWXAPI的实例
   api = WXAPIFactory.createWXAPI(this, CommonConstants.WXAPP_ID, false);
   api.handleIntent(getIntent(), this);
 }
  private void pay(JSONArray params, final CallbackContext callbackContext)
      throws JSONException, MalformedURLException, IOException {
    // 微信支付
    // 返回值:0-成功;1-微信未安装;2-发送失败
    // 参数,传入时按顺序(partnerId,prepayId,timeStamp,nonceStr,sign)

    if (!api.isWXAppInstalled()) {
      callbackContext.error(ERR_WECHAT_NOT_INSTALLED);
      return;
    }
    if (params == null) {
      callbackContext.error(ERR_INVALID_OPTIONS);
      return;
    }

    final PayReq req = new PayReq();
    req.appId = getAppId();
    req.partnerId = params.getString(0);
    req.prepayId = params.getString(1);
    req.timeStamp = params.getString(2);
    req.nonceStr = params.getString(3);
    req.sign = params.getString(4);
    req.packageValue = "Sign=WXPay";

    try {
      boolean success = api.sendReq(req);
      if (!success) {
        callbackContext.error(ERR_SENT_FAILED);
        return;
      } else {
        callbackContext.success(SUCCESS);
      }
    } catch (Exception e) {
      callbackContext.error(e.getMessage());
      return;
    }

    currentCallbackContext = callbackContext;
  }
  public void registerToWX() {

    boolean r = api.registerApp(APP_ID);
    Log.e("debug", "result:" + r);
    String text = "haha";
    // 初始化一个WXTextObject对象
    WXTextObject textObj = new WXTextObject();
    textObj.text = text;

    // 用WXTextObject对象初始化一个WXMediaMessage对象
    WXMediaMessage msg = new WXMediaMessage();
    msg.mediaObject = textObj;
    // 发送文本类型的消息时,title字段不起作用
    // msg.title = "Will be ignored";
    msg.description = text;

    // 构造一个Req
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
    req.message = msg;
    req.scene = SendMessageToWX.Req.WXSceneTimeline; // 调用api接口发送数据到微信
    api.sendReq(req);
  }
        @Override
        public void onClick(View v) {

          switch (v.getId()) {

              // 支付宝支付
            case R.id.zhufu_rel_01:
              boolean connectInternet =
                  NetworkStateUtil.isConnectInternet(LineTeachSelePlayActivity.this);
              if (!connectInternet) {
                WidgetUtil.ToastMessage(
                    LineTeachSelePlayActivity.this,
                    getResources().getString(R.string.connect_net_fail));
                return;
              } else {
                // 2代表支付宝支付
                PostOrderId(orderBean, PLAY_ZH);
                Payment(orderBean);
              }

              break;
              // 微信支付

            case R.id.zhufu_rel_02:
              boolean connectInternet1 =
                  NetworkStateUtil.isConnectInternet(LineTeachSelePlayActivity.this);
              if (!connectInternet1) {
                WidgetUtil.ToastMessage(
                    LineTeachSelePlayActivity.this,
                    getResources().getString(R.string.connect_net_fail));
                return;
              } else {

                if (!msgApi.isWXAppInstalled()) {

                  toastLong("您还没有安装微信!");
                  // 提醒用户没有按照微信
                  return;
                } else {
                  // 3代表微信支付
                  PostOrderId(orderBean, PLAY_WX);
                  WeiXinPlay(orderBean);
                }
              }

              break;
          }
        }
  private void wechatShare(int flag) {
    WXWebpageObject webpage = new WXWebpageObject();
    webpage.webpageUrl = url;
    WXMediaMessage msg = new WXMediaMessage(webpage);
    msg.title = title;
    msg.description = "";
    // 这里替换一张自己工程里的图片资源
    // Bitmap thumb = BitmapFactory.decodeResource(getResources(),
    // R.drawable.action_btn);
    // msg.setThumbImage(thumb);

    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg;
    req.scene =
        flag == 0 ? SendMessageToWX.Req.WXSceneSession : SendMessageToWX.Req.WXSceneTimeline;
    wxApi.sendReq(req);
  }
Beispiel #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pay);
    show = (TextView) findViewById(R.id.editText_prepay_id);
    req = new PayReq();
    sb = new StringBuffer();

    msgApi.registerApp(Constants.APP_ID);
    // 生成prepay_id
    Button payBtn = (Button) findViewById(R.id.unifiedorder_btn);
    payBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            GetPrepayIdTask getPrepayId = new GetPrepayIdTask();
            getPrepayId.execute();
          }
        });
    Button appayBtn = (Button) findViewById(R.id.appay_btn);
    appayBtn.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            sendPayReq();
          }
        });

    // 生成签名参数
    Button appay_pre_btn = (Button) findViewById(R.id.appay_pre_btn);
    appay_pre_btn.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            genPayReq();
          }
        });

    String packageSign = MD5.getMessageDigest(sb.toString().getBytes()).toUpperCase();
  }
  private void initview() {
    // TODO Auto-generated method stub
    txTitle = (TextView) findViewById(R.id.title);
    txTime = (TextView) findViewById(R.id.time);
    txFrom = (TextView) findViewById(R.id.from);
    tvSeenum = (TextView) findViewById(R.id.tv_newsdaly_seenum);

    back = (Button) findViewById(R.id.btn_back);
    btnShare = (Button) findViewById(R.id.btn_newsdayly_share);

    webView = (WebView) findViewById(R.id.webView1);
    layout_content = (LinearLayout) findViewById(R.id.ln_content);

    btn_newscommentadd = (Button) findViewById(R.id.btn_newsdalycomment_add);
    ed_newscomment = (EditText) findViewById(R.id.ed_newsdalycomment_comment);

    back.setOnClickListener(this);
    btn_newscommentadd.setOnClickListener(this);
    btnShare.setOnClickListener(this);

    txTitle.setText(getIntent().getStringExtra("title"));
    txTime.setText(getIntent().getStringExtra("time"));
    txFrom.setText(getIntent().getStringExtra("from"));
    tvSeenum.setText(getIntent().getStringExtra("seenum"));

    a = getIntent().getStringExtra("content");
    webView.loadDataWithBaseURL(null, a, "text/html", "UTF-8", null);
    webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
    webView.getSettings().setDomStorageEnabled(true);

    // 微信注册
    api = WXAPIFactory.createWXAPI(this, APP_ID);
    api.registerApp(APP_ID);

    stitle = getIntent().getStringExtra("title");
    surl = getIntent().getStringExtra("url");
  }
  @Override
  public void onClick(View arg0) {
    switch (arg0.getId()) {
      case R.id.btn_back:
        finish();
        break;
      case R.id.btn_newsdalycomment_add:
        addComment();
        break;
      case R.id.btn_newsdayly_share:
        // 启动微信
        // Toast.makeText(this, String.valueOf(api.openWXApp()),
        // Toast.LENGTH_LONG)
        // .show();
        // 发送文本到朋友圈
        //
        // String text = "application test";
        // WXTextObject textObj = new WXTextObject();
        // textObj.text = text;
        //
        // WXMediaMessage msg = new WXMediaMessage(textObj);
        // msg.mediaObject = textObj;
        // msg.description = text;
        //
        // SendMessageToWX.Req req = new SendMessageToWX.Req();
        // req.transaction = String.valueOf(System.currentTimeMillis());
        // req.message = msg;
        // req.scene = SendMessageToWX.Req.WXSceneTimeline;
        //
        // api.sendReq(req);

        // Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
        // R.drawable.ic_seehdu);
        // WXImageObject imgobj = new WXImageObject(bitmap);
        // WXMediaMessage msg = new WXMediaMessage();
        // msg.mediaObject = imgobj;
        // Bitmap thumbitmap = Bitmap.createScaledBitmap(bitmap, 120, 150,
        // true);
        // bitmap.recycle();
        // msg.thumbData = bmpToArray(thumbitmap, true);
        // SendMessageToWX.Req req = new SendMessageToWX.Req();
        // req.transaction = String.valueOf(System.currentTimeMillis());
        // req.message = msg;
        // req.scene = SendMessageToWX.Req.WXSceneTimeline;
        // api.sendReq(req);
        //
        WXWebpageObject webpage = new WXWebpageObject();
        webpage.webpageUrl = surl;
        WXMediaMessage msg = new WXMediaMessage(webpage);
        msg.title = stitle;
        msg.description = "application test";
        msg.mediaObject = webpage;
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_seehdu);
        Bitmap thumbitmap = Bitmap.createScaledBitmap(bitmap, 120, 150, true);
        bitmap.recycle();
        msg.thumbData = bmpToArray(thumbitmap, true);
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;
        req.scene = SendMessageToWX.Req.WXSceneTimeline;

        api.sendReq(req);
    }
  }
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   wxApi = WXAPIFactory.createWXAPI(this, AppConfig.WX_APP_ID, true);
   wxApi.handleIntent(getIntent(), this);
 }
Beispiel #27
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, true);
   api.handleIntent(getIntent(), this);
 }
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.publics_webview);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    try {
      if (getIntent().hasExtra("internal")) {
        isInternal = getIntent().getStringExtra("internal").equals("1");
      }
    } catch (Exception e) {
      isInternal = false;
    }

    // 微信注册
    api = WXAPIFactory.createWXAPI(this, appId, false);
    api.registerApp(appId);

    url = this.getIntent().getStringExtra("url");
    String title = "";
    if (getIntent().hasExtra("from")) {
      title = "历史消息";
      if (getIntent().hasExtra("marker")) {
        title = getIntent().getStringExtra("marker"); // 来自工作圈跳转
        // Social_WorkGroupListAdapter
        String id = getIntent().getStringExtra("id"); // 来自工作圈跳转
        String pic = getIntent().getStringExtra("img");
        String msgTitle = getIntent().getStringExtra("msgtitle");
        String cnname = getIntent().getStringExtra("cnname");
        if (pic.contains(Pub_HttpUtils.BASE_URL)) {
          pic = pic.replace(Pub_HttpUtils.BASE_URL, "");
        }

        msgData = new Pub_MenuContent();
        msgData.setId(id);
        msgData.setPic(pic);
        msgData.setTitle(msgTitle);
        msgData.setName(cnname);
      }
    } else {
      title = getIntent().getStringExtra("title");
      if (getIntent().hasExtra("specialMsg")) {
        Pub_message msg = (Pub_message) getIntent().getSerializableExtra("specialMsg");
        if (msg != null) {
          msgData = new Pub_MenuContent();
          msgData.setId(msg.getId());
          msgData.setPic("");
          msgData.setTitle("网页链接");
          msgData.setName("");
        }
      } else if (getIntent().hasExtra("fromMenu")) { // 菜单跳转
        msgData = new Pub_MenuContent();
        msgData.setId("0x123");
        msgData.setPic("");
        msgData.setTitle("网页链接");
        msgData.setName("");
      } else {
        msgData = (Pub_MenuContent) getIntent().getSerializableExtra("msg");
      }
    }

    text = (TextView) findViewById(R.id.textview_title);
    TextView share = (TextView) findViewById(R.id.shareBtn);
    text.setText(title);
    findViewById(R.id.button_left_1)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                IntentAnimUtil.backword(Pub_WebViewActivity.this);
              }
            });

    if (title.equals("历史消息")) {
      share.setVisibility(View.GONE);
    } else {
      share.setVisibility(View.VISIBLE);
      share.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              // TODO 分享到工作圈
              SharePopupWindow window = new SharePopupWindow(Pub_WebViewActivity.this);
              window.showAtLocation(
                  findViewById(R.id.public_root_view),
                  Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,
                  0,
                  0);
              // ActionSheet.createBuilder(Pub_WebViewActivity.this,
              // getSupportFragmentManager())
              // .setCancelButtonTitle("取 消")
              // .setOtherButtonTitles("分享到海航圈", "分享给好友" , "分享到微信朋友圈",
              // "分享给微信好友")
              // .setCancelableOnTouchOutside(true)
              // .setListener(Pub_WebViewActivity.this)
              // .show();
            }
          });
    }

    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setBuiltInZoomControls(true);
    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setSupportZoom(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setDefaultTextEncodingName("UTF-8");
    webview.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            try {
              if (url.startsWith("hnairpublic")) {
                String user = url.substring(url.indexOf("=") + 1, url.length());
                Intent intent =
                    new Intent(Pub_WebViewActivity.this, Pub_OfficialAccountInfoActivity.class);
                intent.putExtra("user", user);
                IntentAnimUtil.startActivityWithSlideForward(
                    Pub_WebViewActivity.this, intent, false);
                return true;
              }
              String fileClass = url.substring(url.lastIndexOf(".") + 1);
              if (fileClass.equalsIgnoreCase("apk")) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse(url);
                intent.setData(content_url);
                startActivity(intent);
                return true;
              }
            } catch (Exception e) {
              webview.loadUrl(url);
              return true;
            }
            webview.loadUrl(url);
            return true;
          }
        });
    webview.loadUrl(url);
  }
Beispiel #29
0
 private void sendPayReq() {
   msgApi.registerApp(Constants.APP_ID);
   msgApi.sendReq(req);
 }
 private void initWxShare() {
   // 实例化
   wxApi = WXAPIFactory.createWXAPI(this, APP_ID);
   wxApi.registerApp(APP_ID);
 }