The document describes building a camera app with Android. It includes:
- Using an implicit intent to launch the device's default camera app and receive an image
- Designing layouts with a ConstraintLayout containing TextView, ImageView and ImageButton widgets
- Implementing a click listener on the ImageButton to open the camera, handle the result, and display the image
- Saving captured photos externally by requesting storage permissions and specifying a file location
The document describes building a camera app with Android. It includes:
- Using an implicit intent to launch the device's default camera app and receive an image
- Designing layouts with a ConstraintLayout containing TextView, ImageView and ImageButton widgets
- Implementing a click listener on the ImageButton to open the camera, handle the result, and display the image
- Saving captured photos externally by requesting storage permissions and specifying a file location
The document describes building a camera app with Android. It includes:
- Using an implicit intent to launch the device's default camera app and receive an image
- Designing layouts with a ConstraintLayout containing TextView, ImageView and ImageButton widgets
- Implementing a click listener on the ImageButton to open the camera, handle the result, and display the image
- Saving captured photos externally by requesting storage permissions and specifying a file location
The document describes building a camera app with Android. It includes:
- Using an implicit intent to launch the device's default camera app and receive an image
- Designing layouts with a ConstraintLayout containing TextView, ImageView and ImageButton widgets
- Implementing a click listener on the ImageButton to open the camera, handle the result, and display the image
- Saving captured photos externally by requesting storage permissions and specifying a file location
Download as PPTX, PDF, TXT or read online from Scribd
Download as pptx, pdf, or txt
You are on page 1of 12
CAMERA: TAKE PHOTOES
MABASA NYASHA MUTYAMBIZI
202025800045 CONTENTS ■ Introduction ■ Layout design ■ System implementation ■ Take pictures ■ Display images ■ External Storage INTRODUCTION ■ The android framework includes support for various cameras and camera features available on the devices that allows us to capture pictures in your apps. ■ In this project an implicit intent is used to start up the user’s camera application as well as receive an image from it. ■ There are two ways to use the camera: - - Using the default android camera - Directly using the Camera API Layout ■ A layout is a container that is derived from the android.view.ViewGroup which is used as a container for other views. ■ It is used to group and arrange views visually on the screen. ■ In this project we used the ContraintLayout. Necessary UIs ■ TextView – Commonly known as the Label View – It is read only as it display the text on the screen in this case my app name. ■ ImageView – A view that shows images on the device screen. – Sets a drawable as the content. ■ ImageButton – Represents a push-button widget. – Contains the camera image drawable The Camera Layout Layout Design Layout xml code THE JAVA CODE ■ First part of the code. ■ Declare the variables and find the views based on their resource Ids then assign them to the variables. ■ Set the event implementation using setOnclickListener on the button(ImageButton). Take Photo on Button Click ■ In the java Code, Declare the variables and find the views based on their resource Ids then assign them to the variables as well as the variable for request code ■ We find the ImageButton in the xml file by ID and cast it to the ImageButton object. ■ Then implement the button click event by Anonymous implementation. ■ Pass the specific request for the android OS to open the default camera ■ Open the camera with intent by calling the startActivityForResult method. ■ The following code illustrates the steps: DISPLAY IMAGE TAKEN ■ We create onActivityResult ■ Check if the request is camera ■ The camera returns back to the app with the image data located in the intent (data extra for rendering) ■ Get the captured image ■ Set the image to the image view. TESTING RESULTS BEFORE AFTER PICTURE STORAGE ■ We allocate an external Storage location for the images captured. ■ First we need a permission to access the location, android.permissions.WRITE_EXTERNAL_STORAGE. ■ Pass the file location. ■ You can call the getExternalFileDir() the pass in the picture environment ■ We can specify the the file name, suffix and the location. ■ We pass it in as an exta to the intent using putExtra(MediaStore.EXTRA_OUTPUT) THANK YOU !!