[英]how to get the real path of the Uri which handled from whatsApp
I tried to copy the files from folder to another all my code works fine, but when I tried to move the file which handled from whatsApp an error happened that is我试图将文件从文件夹复制到另一个我的所有代码都可以正常工作,但是当我尝试移动从whatsApp处理的文件时发生了错误
column '_data' does not exist列“_data”不存在
when I handle the file from Media it works fine and the Uri is:当我处理来自 Media 的文件时,它工作正常并且 Uri 是:
content://media/external/audio/media/52889内容://媒体/外部/音频/媒体/52889
but if the file handled from whatsApp the Uri would be:但如果从 WhatsApp 处理的文件,则 Uri 将是:
content://com.whatsapp.provider.media/item/5033内容://com.whatsapp.provider.media/item/5033
So how can I get the real path of the Uri is coming from whatsApp那么我怎样才能得到Uri的真实路径来自whatsApp
here is the Log Cat:这是原木猫:
Caused by: java.lang.NullPointerException: println needs a message引起:java.lang.NullPointerException: println 需要一条消息
I appreciate any help, and thanks for advance感谢您的帮助,并感谢您的提前
Try to create an InputStream object of URI received from WhatsApp or any 3rd party app.尝试创建从 WhatsApp 或任何第 3 方应用程序接收的 URI 的 InputStream 对象。 Doing so enables one to upload the media to a server or perform other tasks.这样做可以将媒体上传到服务器或执行其他任务。
Intent intent = getIntent();
imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
InputStream is = getContentResolver().openInputStream(imageUri);
Note:- This must be performed as soon as one receives the intent or in the same base activity.注意:-这必须在收到意图后立即执行或在同一基本活动中执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.