使用图库图标启动相机意图
我正在开发一个访问相机并返回 uri 的应用程序,我将其传递给另一个活动并在 ImageView 中显示提取的位图。一切似乎都运转良好。这是我用来启动相机意图的代码。
mCameraButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCameraUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraUri);
mtimeCameraAcessed = System.currentTimeMillis();
startActivityForResult(cameraIntent, RECEIVE_CAMERA_PICTURE);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
但是,我注意到了一个差异。当我的应用程序访问相机时,屏幕底部的图库图标似乎丢失了(当您在任何 Android 手机上访问相机应用程序时会出现该图标)。我附上了几个屏幕截图来说明这一点。
我希望用户在访问相机的同时能够改变主意,然后在同一屏幕上访问图库(通过点击图库图标)。现在,我知道如何通过“Intent.ACTION_PICK”启动图库意图。我也看过这个问题,但我不完全同意我需要自定义相机布局来实现我想要做的事情: 让用户在 Android 中拍照或从图库中选择图像的单一意图
我这么说的原因是因为,我有见过 QuickPic 等应用程序通过底部的图库图标访问相机应用程序。有人能解释一下吗?
I am working on an app that accesses the camera and returns an uri, which I pass to another activity and display the extracted bitmap in an ImageView. Everything seems to work fine. Here is the code that I use to initiate the camera intent.
mCameraButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCameraUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraUri);
mtimeCameraAcessed = System.currentTimeMillis();
startActivityForResult(cameraIntent, RECEIVE_CAMERA_PICTURE);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
But, I have noticed a discrepancy. When my application access the camera, the gallery icon at the bottom of the screen seems to be missing (the icon appears when you access the camera application on any android phone). I have attached a couple of screenshots to illustrate this.
I want the user to access the camera while being able to change his/her mind and then access the gallery on the same screen (by tapping the gallery icon). Now, I do know how to initiate a gallery intent via 'Intent.ACTION_PICK'. I have also looked at the this question, but I don't completely agree that I need a custom camera layout to achieve what I intend to do: Single intent to let user take picture OR pick image from gallery in Android
The reason I say this is because, I have seen apps such as QuickPic that access the camera application with the gallery icon at the bottom. Can anyone please throw some light on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番彻底的研究后,我得出的结论是,这实际上是不可能的。然而,如果需要这样的东西,自定义布局与相机 API 结合将是理想的解决方案。但随后,我发现使用相机 api 存在某些问题,例如相机屏幕的外观倾斜。
QuickPic 将用户带到相机屏幕(带有图库图标),但在此过程中将他/她从应用程序中删除。此时,用户基本上使用的是 Android 上的内置相机应用程序,而不是 Quickpic 应用程序本身。
After going through some thorough research, I have come to a conclusion that this is infact impossible. However, a custom layout combined with the camera api would be the ideal solution if something like this is desired. But then, I have observed that using the camera api has certain problems such as skewed appearance of the camera screen.
QuickPic takes the user to the camera screen (with the gallery icon) but drops him/her out of the app while doing so. At that point, the user is basically using the stock camera app on Android and not the Quickpic app itself.