正在显示
2 个修改的文件
包含
76 行增加
和
1 行删除
| @@ -306,6 +306,68 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv | @@ -306,6 +306,68 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv | ||
| 306 | } | 306 | } |
| 307 | _share(SendMessageToWX.Req.WXSceneSession, data, callback); | 307 | _share(SendMessageToWX.Req.WXSceneSession, data, callback); |
| 308 | } | 308 | } |
| 309 | + /** | ||
| 310 | + * 采用自带分享到 微信 | ||
| 311 | + * @param uri | ||
| 312 | + */ | ||
| 313 | + @ReactMethod | ||
| 314 | + public void shareWechatFriend(final ReadableArray array) { | ||
| 315 | + Callback callback=new Callback() { | ||
| 316 | + @Override | ||
| 317 | + public void invoke(Object... args) { | ||
| 318 | + if(args.equals(NOT_REGISTERED)){ | ||
| 319 | + Toast.makeText(getReactApplicationContext(),"您需要安装微信客户端", Toast.LENGTH_LONG).show(); | ||
| 320 | + }else{ | ||
| 321 | + ArrayList<Uri> list = new ArrayList<>(); | ||
| 322 | + if(array.size()!=0){ | ||
| 323 | + for (int i = 0; i < array.size(); i++) { | ||
| 324 | + if (ReadableType.String == array.getType(i)) { | ||
| 325 | + list.add(Uri.parse(array.getString(i))); | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + }else{ | ||
| 330 | + Toast.makeText(getReactApplicationContext(),"图片数组不正确", Toast.LENGTH_LONG).show(); | ||
| 331 | + return; | ||
| 332 | + } | ||
| 333 | +// String uris = getFilePathFromContentUri(getReactApplicationContext(),imageUri); | ||
| 334 | +// File picFile = new File(uris); | ||
| 335 | +// Log.i("Tag1213","das"+uris); | ||
| 336 | +// Log.i("Tag1213","das"+picFile.isFile()); | ||
| 337 | +// Log.i("Tag1213","das"+picFile.exists()); | ||
| 338 | +// if (picFile.isFile() && picFile.exists()) { | ||
| 339 | +// | ||
| 340 | +// Uri uri; | ||
| 341 | +// if ( Build.SDK_INT >= 24) { | ||
| 342 | +// uri = FileProvider.getUriForFile(getReactApplicationContext(), "com.vodeapp.umeng.message", picFile); | ||
| 343 | +// } else { | ||
| 344 | +// uri = Uri.fromFile(picFile); | ||
| 345 | +// } | ||
| 346 | +// Log.i("Tag1213","das"+picFile.exists()+uri); | ||
| 347 | +// | ||
| 348 | +//// intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri); | ||
| 349 | +// } | ||
| 350 | + Intent intent = new Intent(); | ||
| 351 | + //分享精确到微信的页面,朋友圈页面,或者选择好友分享页面 | ||
| 352 | + ComponentName cop = new ComponentName("com.tencent.mm","com.tencent.mm.ui.tools.ShareImgUI"); | ||
| 353 | + intent.setComponent(cop); | ||
| 354 | + intent.setAction(Intent.ACTION_SEND); | ||
| 355 | + intent.setType("image/*"); | ||
| 356 | + | ||
| 357 | + | ||
| 358 | + intent.setAction(Intent.ACTION_SEND_MULTIPLE); //多个需要 设置这个参数 | ||
| 359 | + intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, list); | ||
| 360 | +// intent.putExtra(Intent.EXTRA_STREAM, imageUri); 分享单个 | ||
| 361 | + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 362 | + getReactApplicationContext().startActivity(Intent.createChooser(intent, "Share")); | ||
| 363 | + | ||
| 364 | + } | ||
| 365 | + } | ||
| 366 | + }; | ||
| 367 | + this.isWXAppInstalled(callback); | ||
| 368 | +// getReactApplicationContext | ||
| 369 | + | ||
| 370 | + } | ||
| 309 | 371 | ||
| 310 | @ReactMethod | 372 | @ReactMethod |
| 311 | public void pay(ReadableMap data, Callback callback) { | 373 | public void pay(ReadableMap data, Callback callback) { |
| @@ -407,7 +469,16 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv | @@ -407,7 +469,16 @@ public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEv | ||
| 407 | .build(); | 469 | .build(); |
| 408 | } | 470 | } |
| 409 | } | 471 | } |
| 410 | - | 472 | + private String getFilePathFromContentUri(Context context,Uri contentUri){ |
| 473 | + Cursor cursor = null; | ||
| 474 | + String[] proj = { MediaStore.Images.Media.DATA }; | ||
| 475 | + cursor = context.getContentResolver().query(contentUri, proj, null, null, null); | ||
| 476 | + cursor.moveToFirst(); | ||
| 477 | + int column_index = cursor.getColumnIndex(proj[0]); | ||
| 478 | + String path = cursor.getString(column_index); | ||
| 479 | + return path; | ||
| 480 | +// Cursor cursor = contentResolver.query(selectedVideoUri, filePathColumn, null, null, null); | ||
| 481 | + } | ||
| 411 | private void _share(final int scene, final ReadableMap data, final Bitmap thumbImage, final Callback callback) { | 482 | private void _share(final int scene, final ReadableMap data, final Bitmap thumbImage, final Callback callback) { |
| 412 | if (!data.hasKey("type")) { | 483 | if (!data.hasKey("type")) { |
| 413 | callback.invoke(INVALID_ARGUMENT); | 484 | callback.invoke(INVALID_ARGUMENT); |
-
请 注册 或 登录 后发表评论