|
- private void sendMiniApps(String articlePk, String title, String content,
- String url, Bitmap icon) {
-
- WXMiniProgramObject miniProgram = new WXMiniProgramObject();
- //低版本微信打开 URL
- miniProgram.webpageUrl = url;
- //跳转的小程序的原始 ID
- miniProgram.userName = WechatShareUtils.MINI_APPS_ID;
- //小程序的 Path
- miniProgram.path = WechatShareUtils.getMiniAppPath(articlePk);
-
- WXMediaMessage msg = new WXMediaMessage(miniProgram);
- final String shareTitle = WechatShareUtils.getValidTitle(title);
- if (!TextUtils.isEmpty(shareTitle)) {
- msg.title = title;
- }
-
- final String shareDescription = WechatShareUtils.getValidDescription(content);
- if (!TextUtils.isEmpty(shareDescription)) {
- msg.description = shareDescription;
- }
-
- if (icon != null) {
- msg.setThumbImage(icon);
- } else {
- Bitmap temp = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.icon_wechat);
- msg.setThumbImage(temp);
- }
-
- Log.i("TAG", "sendMiniApps title: " + title);
-
- //使用此方法会出现无法分享的问题
- // Bitmap thumbBmp = Bitmap.createScaledBitmap(icon, 150, 150, true);
- // icon.recycle();
- // msg.thumbData = BitmapUtils.bitmapToByteArray(thumbBmp, true);
-
-
- SendMessageToWX.Req req = new SendMessageToWX.Req();
- req.transaction = buildTransaction("miniProgram");
- req.message = msg;
- req.scene = WXSceneSession;
- api.sendReq(req);
-
- }
|
|