While use camera in my application close current screen

I am creating a application for uploading Images form camera and gallary,

1) if i press camera button in my app i want to capture image and show that image to current screen.

2)currenltly i'm using the below functioin to do that, but at first use of the app user is asked to give permission to use camera after that if we allow then the current screen is closed. before that it is capturing the image.

3) If the use the same app after exiting second time there is no closing of the current screen and it working fine.

Any suggestions. can we give permissions like the usage of camera even before installing app like in android permissions.