I have created an app with a button and wrote onClickListener for that button. I have tried several sample code examples and none of them worked. They all bring up the Android camera app and don’t take photographs. I want some code which I can put in my onClickListener so when I press the button on the screen, a picture will be taken.
How can I make the camera take a picture when I press a button in an Android activity?
Look at following demo code.
Here is your XML file for UI,
And here is your Java class file,
Note:
Specify the following permissions in your manifest file,