|
...
|
...
|
@@ -306,6 +306,68 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv |
|
|
|
}
|
|
|
|
_share(SendMessageToWX.Req.WXSceneSession, data, callback);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 采用自带分享到 微信
|
|
|
|
* @param uri
|
|
|
|
*/
|
|
|
|
@ReactMethod
|
|
|
|
public void shareWechatFriend(final ReadableArray array) {
|
|
|
|
Callback callback=new Callback() {
|
|
|
|
@Override
|
|
|
|
public void invoke(Object... args) {
|
|
|
|
if(args.equals(NOT_REGISTERED)){
|
|
|
|
Toast.makeText(getReactApplicationContext(),"您需要安装微信客户端", Toast.LENGTH_LONG).show();
|
|
|
|
}else{
|
|
|
|
ArrayList<Uri> list = new ArrayList<>();
|
|
|
|
if(array.size()!=0){
|
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
|
if (ReadableType.String == array.getType(i)) {
|
|
|
|
list.add(Uri.parse(array.getString(i)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
Toast.makeText(getReactApplicationContext(),"图片数组不正确", Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// String uris = getFilePathFromContentUri(getReactApplicationContext(),imageUri);
|
|
|
|
// File picFile = new File(uris);
|
|
|
|
// Log.i("Tag1213","das"+uris);
|
|
|
|
// Log.i("Tag1213","das"+picFile.isFile());
|
|
|
|
// Log.i("Tag1213","das"+picFile.exists());
|
|
|
|
// if (picFile.isFile() && picFile.exists()) {
|
|
|
|
//
|
|
|
|
// Uri uri;
|
|
|
|
// if ( Build.SDK_INT >= 24) {
|
|
|
|
// uri = FileProvider.getUriForFile(getReactApplicationContext(), "com.vodeapp.umeng.message", picFile);
|
|
|
|
// } else {
|
|
|
|
// uri = Uri.fromFile(picFile);
|
|
|
|
// }
|
|
|
|
// Log.i("Tag1213","das"+picFile.exists()+uri);
|
|
|
|
//
|
|
|
|
//// intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri);
|
|
|
|
// }
|
|
|
|
Intent intent = new Intent();
|
|
|
|
//分享精确到微信的页面,朋友圈页面,或者选择好友分享页面
|
|
|
|
ComponentName cop = new ComponentName("com.tencent.mm","com.tencent.mm.ui.tools.ShareImgUI");
|
|
|
|
intent.setComponent(cop);
|
|
|
|
intent.setAction(Intent.ACTION_SEND);
|
|
|
|
intent.setType("image/*");
|
|
|
|
|
|
|
|
|
|
|
|
intent.setAction(Intent.ACTION_SEND_MULTIPLE); //多个需要 设置这个参数
|
|
|
|
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, list);
|
|
|
|
// intent.putExtra(Intent.EXTRA_STREAM, imageUri); 分享单个
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
getReactApplicationContext().startActivity(Intent.createChooser(intent, "Share"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.isWXAppInstalled(callback);
|
|
|
|
// getReactApplicationContext
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
public void pay(ReadableMap data, Callback callback) {
|
|
...
|
...
|
@@ -407,7 +469,16 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv |
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private String getFilePathFromContentUri(Context context,Uri contentUri){
|
|
|
|
Cursor cursor = null;
|
|
|
|
String[] proj = { MediaStore.Images.Media.DATA };
|
|
|
|
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
|
|
|
cursor.moveToFirst();
|
|
|
|
int column_index = cursor.getColumnIndex(proj[0]);
|
|
|
|
String path = cursor.getString(column_index);
|
|
|
|
return path;
|
|
|
|
// Cursor cursor = contentResolver.query(selectedVideoUri, filePathColumn, null, null, null);
|
|
|
|
}
|
|
|
|
private void _share(final int scene, final ReadableMap data, final Bitmap thumbImage, final Callback callback) {
|
|
|
|
if (!data.hasKey("type")) {
|
|
|
|
callback.invoke(INVALID_ARGUMENT);
|
...
|
...
|
|