分享图像文件的缓存目录通过意向〜机器人缓存、机器人、意向、图像文件

2023-09-05 08:39:46 作者:恋爱的笔 诠释青春ゝ

我试图在高速缓存目录共享图像文件,我有完整的路径,但无法发送的文件附件中,code是

 文件shareImage = Utils.getBitmapFile();
Log.d(活动,得到最终的路径的结果+ shareImage.getAbsolutePath());
/ * MimeTypeMap MIME = MimeTypeMap.getSingleton();
串分机= shareImage.getName()子(shareImage.getName()lastIndexOf()+1。。)。
字符串类型= mime.getMimeTypeFromExtension(分机);
shareIntent.setType(类型);
意图shareIntent =新的意图(Intent.ACTION_SEND);
shareIntent.setType(图像/ *);
乌里shareImageUri = Uri.fromFile(shareImage);
乌里shareImageUri = Uri.fromParts(内容,shareImage.getAbsolutePath(),NULL); //(内容://+ shareImage.getAbsolutePath());
* /


乌里shareImageUri = Uri.fromFile(shareImage);
Log.d(结果,uri为+ shareImageUri.toString());
shareIntent.putExtra(Intent.EXTRA_STREAM,shareImageUri);
startActivity(Intent.createChooser(shareIntent,分享成果));
 

以上评论code不工作

发送邮件显示附件,但没有收到到底有没有附件, Facebook的共享也显示了后没有图像

什么原因?

我已经看到下面的SO链接how-to-use-share-image-using-sharing-intent-to-share-images-in-android和许多人一样,没有人能够解决这个问题。

P.S;

1,目的是把屏幕截图保存它的缓存目录,并从那里的在线共享

2.Yes我确实有文件,我可以通过DDMS从设备拉一下,看看系统。

解决方案   

什么原因呢?

如前所述,其他应用程序不能访问到您的应用程序的内部存储。

  

没有人能够解决这个问题。

随意打开一个新的StackOverflow的问题,在这里你解释,完全和precisely 什么具体的解决方案,您试图同时你又遇到了什么具体的问题。

  

但是,这并不似乎是工作按SO发布!

随意打开一个新的StackOverflow的问题,在这里你解释,完全和precisely 什么叫不似乎是工作的的意思。

或者,使用 FileProvider ,它提供了这个功能需要超越您的清单把新的纪录没有code。

或者存储您的外部存储,如图像getExternalCacheDir()

I am trying to share image file in cache directory, i have the complete path, but not able to send the file in attachments, the code is

File shareImage=Utils.getBitmapFile();
Log.d("Activity", "get final path in result"+shareImage.getAbsolutePath());
/*MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext=shareImage.getName().substring(shareImage.getName().lastIndexOf(".")+1);
String type = mime.getMimeTypeFromExtension(ext);
shareIntent.setType(type);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri shareImageUri = Uri.fromFile(shareImage);
Uri shareImageUri = Uri.fromParts("content", shareImage.getAbsolutePath(), null);//("content://"+shareImage.getAbsolutePath()); 
*/


Uri shareImageUri = Uri.fromFile(shareImage);
Log.d("Result ","uri is "+shareImageUri.toString());
shareIntent.putExtra(Intent.EXTRA_STREAM, shareImageUri);
startActivity(Intent.createChooser(shareIntent, "Share Results"));

the above commented code is not working

the send mail shows attachment,but not receiving end there is not attachment, facebook sharing also shows no image in post

what the reason for this??

I have already seen the following SO Links how-to-use-share-image-using-sharing-intent-to-share-images-in-android and many others, none of them are able to resolve the issue

P.S.;

1.The aim is to take screenshot of screen save it in cache directory and share it online from there

2.Yes i do have file, I can pull it via DDMS from device and see on system.

解决方案

what the reason for this?

As noted, other apps do not have access to your app's internal storage.

none of them are able to resolve the issue

Feel free to open a fresh StackOverflow question, where you explain, completely and precisely what specific solutions you have tried and what specific problems you have encountered.

but that does not seems to be working as per SO post!!!

Feel free to open a fresh StackOverflow question, where you explain, completely and precisely what "that does not seems to be working" means.

Or, use FileProvider, which offers this capability with no code required beyond an entry for it in your manifest.

Or, store your image on external storage, such as getExternalCacheDir().