Initiate Camera Intent with the Gallery Icon

青春壹個敷衍的年華 提交于 2019-12-10 17:44:41

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8932329/initiate-camera-intent-with-the-gallery-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!