简体   繁体   English

使用图库图标启动相机意图

[英]Initiate Camera Intent with the Gallery Icon

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. 我正在开发一个访问相机并返回一个uri的应用程序,我将其传递给另一个活动并在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). 当我的应用程序访问相机时,屏幕底部的图库图标似乎丢失(当您在任何Android手机上访问相机应用程序时会出现图标)。 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'. 现在,我知道如何通过'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 我也看过这个问题,但我并不完全同意我需要一个自定义的相机布局来实现我打算做的事: 单一意图让用户拍照或从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. 我说这个的原因是因为,我看过像QuickPic这样的应用程序可以通过底部的图库图标访问相机应用程序。 Can anyone please throw some light on this? 任何人都可以对此有所了解吗?

相机与画廊图标

没有画廊图标的相机

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. 但是,如果需要这样的东西,自定义布局与相机api相结合将是理想的解决方案。 But then, I have observed that using the camera api has certain problems such as skewed appearance of the camera screen. 但后来我发现使用相机api有一些问题,比如相机屏幕的外观偏斜。

QuickPic takes the user to the camera screen (with the gallery icon) but drops him/her out of the app while doing so. QuickPic将用户带到相机屏幕(带有图库图标),但同时将他/她从应用程序中删除。 At that point, the user is basically using the stock camera app on Android and not the Quickpic app itself. 此时,用户基本上是在Android上使用相机应用程序而不是Quickpic应用程序本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM