无法正确获取“ android.intent.action.SEND”意图的路径

罗伊斯·拉朱·比恩

我可以通过以下代码将路径传递给另一个类

private void sendImageFromCameraIntent() {
    Intent intent = getActivity().getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type.startsWith("image/")) {
        Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
        if (imageUri != null) {
            String path = imageUri.getPath();
            Toast.makeText(getContext(), path, Toast.LENGTH_SHORT).show();
            imageShared = true;
            inputPanel.sendImage(path);
        }
    }
}

但是在另一类中,以下检查失败

 public int sendImage(String path) {
    if (path != null && new File(path).isFile()) {
     // code to send image - works fine when adding an attachment

     return 1;
   }
   else return -1

路径在吐司中显示,但返回值为-1

罗伊斯·拉朱·比恩

我将getPath更改为

String path = FileUtils.getPath(getActivity(), imageUri);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

从android Intent.ACTION_SEND中提取文件路径

来自分类Dev

Android android.intent.action.SEND youtube video

来自分类Dev

getActivity()调用导致RuntimeException:无法启动Intent Intent act = android.intent.action.MAIN

来自分类Dev

getActivity()调用导致RuntimeException:无法启动Intent Intent act = android.intent.action.MAIN

来自分类Dev

Android Intent ACTION_CALL无法拨打电话

来自分类Dev

android.intent.action.MY_PACKAGE_REPLACED无法正常工作

来自分类Dev

无法捕获android.intent.action.MEDIA_BUTTON

来自分类Dev

Android Intent ACTION_CALL无法拨打电话

来自分类Dev

从股票Google相册应用共享照片时,列表中未显示带有“ android.intent.action.SEND”意图过滤器的活动

来自分类Dev

android.intent.action.BOOT_COMPLETED在“重新启动”或“重新启动”时未收到意图

来自分类Dev

android“android.intent.action.SEND”在已经运行的活动中传递它

来自分类Dev

Android 5中的Intent Action Call

来自分类Dev

Android 5中的Intent Action Call

来自分类Dev

关于android.intent.action.BOOT_COMPLETED

来自分类Dev

[Android] Intent.ACTION_VIEW-找不到

来自分类Dev

Android = TelephonyManager (Intent.ACTION_CALL)

来自分类Dev

使用ACTION_IMAGE_CAPTURE Intent时如何正确地错误捕获Android相机活动

来自分类Dev

使用“ android.intent.action.SEND”时,接收活动不会返回到发起共享的活动

来自分类Dev

如何使用Android Share Intent Chooser(ACTION_SEND)收听/捕捉社交媒体共享的成功事件?

来自分类Dev

Android ACTION_SEND意图未填充主题或正文

来自分类Dev

Android Intent无法启动

来自分类Dev

Intent.ACTION_SEND不发送附件

来自分类Dev

Android 9Intent。ACTION_UNINSTALL_PACKAGE无法正常工作

来自分类Dev

BroadcastReceiver没有收到意图Intent。ACTION_LOCALE_CHANGED

来自分类Dev

从Android NFC Intent获取URI

来自分类Dev

无法解决Intent Service Android

来自分类Dev

为什么在Android中使用Intent.ACTION_PICK时文件管理器App无法正常工作?

来自分类常见问题

android.intent.action.MAIN是什么意思?

来自分类Dev

Android Intent.ACTION_VIEW基本身份验证

Related 相关文章

  1. 1

    从android Intent.ACTION_SEND中提取文件路径

  2. 2

    Android android.intent.action.SEND youtube video

  3. 3

    getActivity()调用导致RuntimeException:无法启动Intent Intent act = android.intent.action.MAIN

  4. 4

    getActivity()调用导致RuntimeException:无法启动Intent Intent act = android.intent.action.MAIN

  5. 5

    Android Intent ACTION_CALL无法拨打电话

  6. 6

    android.intent.action.MY_PACKAGE_REPLACED无法正常工作

  7. 7

    无法捕获android.intent.action.MEDIA_BUTTON

  8. 8

    Android Intent ACTION_CALL无法拨打电话

  9. 9

    从股票Google相册应用共享照片时,列表中未显示带有“ android.intent.action.SEND”意图过滤器的活动

  10. 10

    android.intent.action.BOOT_COMPLETED在“重新启动”或“重新启动”时未收到意图

  11. 11

    android“android.intent.action.SEND”在已经运行的活动中传递它

  12. 12

    Android 5中的Intent Action Call

  13. 13

    Android 5中的Intent Action Call

  14. 14

    关于android.intent.action.BOOT_COMPLETED

  15. 15

    [Android] Intent.ACTION_VIEW-找不到

  16. 16

    Android = TelephonyManager (Intent.ACTION_CALL)

  17. 17

    使用ACTION_IMAGE_CAPTURE Intent时如何正确地错误捕获Android相机活动

  18. 18

    使用“ android.intent.action.SEND”时,接收活动不会返回到发起共享的活动

  19. 19

    如何使用Android Share Intent Chooser(ACTION_SEND)收听/捕捉社交媒体共享的成功事件?

  20. 20

    Android ACTION_SEND意图未填充主题或正文

  21. 21

    Android Intent无法启动

  22. 22

    Intent.ACTION_SEND不发送附件

  23. 23

    Android 9Intent。ACTION_UNINSTALL_PACKAGE无法正常工作

  24. 24

    BroadcastReceiver没有收到意图Intent。ACTION_LOCALE_CHANGED

  25. 25

    从Android NFC Intent获取URI

  26. 26

    无法解决Intent Service Android

  27. 27

    为什么在Android中使用Intent.ACTION_PICK时文件管理器App无法正常工作?

  28. 28

    android.intent.action.MAIN是什么意思?

  29. 29

    Android Intent.ACTION_VIEW基本身份验证

热门标签

归档