使用相机拍照,保存到本地——而不是保存到SD卡
正如标题所述,我正在尝试启动相机并拍摄一张可以在本地与应用程序一起使用的照片。这是针对 Motorola Xoom 的,默认情况下,它们不附带 SD 卡。或者至少我的客户正在考虑购买的产品没有 SD 卡。
我找到了一个关于如何启动相机的非常好的教程,我可以让它启动以及物理保存图像然后能够重新使用该图像。
我发现的许多解决方案或其他教程仅展示如何保存到 SD 卡,而不是常驻内存或应用程序本地。看起来可以这样做,但我很困惑。 :-/
As the title states, I'm trying to launch the camera and take a picture that I can use with the APP locally. This is for the Motorola Xoom and, by default, they do not come with SD cards. Or at least the ones my client is looking into purchasing do not have SD cards.
I've found a pretty nice tutorial on how to launch the camera and I can get it to launch and everything up to it physically saving the image and then being able to re-use that image.
A lot of the solutions or other tutorials I've found only show how to save to an SD card -- not to resident memory or local to the app. It looks like it is possible to do so but am stumped. :-/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您也许可以将其加载到 ContentProvider,以便稍后可以将图像用于任何用途:
You could perhaps load it to ContentProvider so that you could use the images later for anything:
查看 Activity.getFilesDir() 和 < a href="http://developer.android.com/reference/android/content/ContextWrapper.html#getCacheDir%28%29" rel="nofollow">Activity.getCacheDir() 它们提供对存储应用程序的存储的访问。另请查看 Environment.getExternalStoragePublicDirectory ()< /a>,外部,这里指的是应用程序的私有目录之外。还有其他几个方法,因此请查看 API 的类似命名方法以找到最适合您的方法。
Check out Activity.getFilesDir() and Activity.getCacheDir() they provide access to storage where the app is stored. Also check out Environment.getExternalStoragePublicDirectory (), external, here, means outside the application's private directories. There are several others so look around the API's similarly named methods to find the best fit for you.
因此,您应该注意的一件事是,当您调用Environment.getExternalStorageDirectory()时,这不一定对应于外部存储空间(即SD卡),并且会返回设备上的本地存储空间,而无需SD 卡插槽。
http://developer.android.com/reference/android/os/Environment .html#getExternalStorageDirectory()
同样适用
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
So one thing you should note is that when you call
Environment.getExternalStorageDirectory()
, this does not necessarily correspond to an external memory space (i.e. and SD card) and would return a local memory space on devices without SD card slots.http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()
The same applies for
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);