安卓三星:相机的应用程序将不会返回intent.getData()

编程入门 行业动态 更新时间:2024-10-11 07:31:41
本文介绍了安卓三星:相机的应用程序将不会返回intent.getData()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开发一个应用程序,其中图像取自原生相机应用。要被显示给用户。 在code我所做的是:

I am developing an app, where an image taken from the native camera app. is to be shown to the user. The code I did is:

/* Intent */ Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, TAKE_PICTURE); /* Result */ onActivityResult(int requestCode, int resultCode, Intent returnIntent) { if(requestCode == TAKE_PICTURE) { //picture from Camera if (resultCode == Activity.RESULT_OK) { if(returnIntent != null) { try { // Get the file path where the image is stored. // This runs fine on all devices, except Samsung ones. Uri selectedImage = returnIntent.getData(); if(selectedImage == null) { if(returnIntent.getExtras() != null && returnIntent.getExtras().get(AppConstants.DATA) != null) { // But, I get the image Bitmap here. Means the image is stored in disk. Bitmap bmp = (Bitmap) returnIntent.getExtras().get(AppConstants.DATA); } } } catch (Exception e) { // } } } } }

这里的问题是,上述code正常工作的我尝试了所有设备(HTC的,SE的),但它在某种程度上未能在三星的。在乌里selectedImage = returnIntent.getData();永远不会返回任何东西。由于我的整个应用程序是建立在文件路径存储的这个逻辑,我无法继续。 有没有什么解决办法的人。

The problem here is, the above code works fine on all devices I tried (HTC's, SE's) but it somehow fails in the Samsung ones. The "Uri selectedImage = returnIntent.getData();" never returns anything. As my entire app is built over this logic of file path storing, I am not able to proceed. Is there any solution people.

推荐答案

见的指定文件名指定的意图,它可以让你指定的文件名画面的EXTRA_OUTPUT参数图片应采取为code。还记得文件名时的活动结果被称为和使用,如果intent.getData为NULL

See Specify filename for picture to be taken for code to specify an EXTRA_OUTPUT parameter for the Intent which lets you specify a filename for the picture. Remember the filename when the activity result is called and use that if the intent.getData is NULL

如果你读这个bug报告中的其他意见,你会发现有多少的问题,照片拍摄于Android已经。

And if you read the other comments in that bug report, you'll realize how many problems that picture taking on Android has.

更多推荐

安卓三星:相机的应用程序将不会返回intent.getData()

本文发布于:2023-08-06 11:21:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1311946.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   相机   卓三星   intent   getData

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!