mirror of
https://github.com/little-snow-fox/react-native-wechat-lib.git
synced 2025-12-06 15:26:49 +08:00
fix 紧急修复 android 上读取本地图片代码错误导致的报错
This commit is contained in:
parent
3b7492fc48
commit
b9524ca994
@ -50,6 +50,8 @@ import com.tencent.mm.opensdk.constants.ConstantsAPI;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -246,7 +248,9 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv
|
|||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void shareLocalImage(final ReadableMap data, final Callback callback) {
|
public void shareLocalImage(final ReadableMap data, final Callback callback) {
|
||||||
FileInputStream fs = new FileInputStream(data.getString("imageUrl"));
|
FileInputStream fs = null;
|
||||||
|
try {
|
||||||
|
fs = new FileInputStream(data.getString("imageUrl"));
|
||||||
Bitmap bmp = BitmapFactory.decodeStream(fs);
|
Bitmap bmp = BitmapFactory.decodeStream(fs);
|
||||||
// 初始化 WXImageObject 和 WXMediaMessage 对象
|
// 初始化 WXImageObject 和 WXMediaMessage 对象
|
||||||
WXImageObject imgObj = new WXImageObject(bmp);
|
WXImageObject imgObj = new WXImageObject(bmp);
|
||||||
@ -263,7 +267,10 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv
|
|||||||
// req.userOpenId = getOpenId();
|
// req.userOpenId = getOpenId();
|
||||||
req.scene = data.hasKey("scene") ? data.getInt("scene") : SendMessageToWX.Req.WXSceneSession;
|
req.scene = data.hasKey("scene") ? data.getInt("scene") : SendMessageToWX.Req.WXSceneSession;
|
||||||
callback.invoke(null, api.sendReq(req));
|
callback.invoke(null, api.sendReq(req));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
callback.invoke(null, false);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-wechat-lib",
|
"name": "react-native-wechat-lib",
|
||||||
"version": "1.1.3",
|
"version": "1.1.5",
|
||||||
"description": "react-native library for wechat app. 支持分享和拉起小程序。",
|
"description": "react-native library for wechat app. 支持分享和拉起小程序。",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user