‫What's up, guys?
‫And welcome again.
‫In the previous videos we have created the bind preview method that on request permission result we
‫override it and we have initialized the widgets and the layouts now.
‫We need to solve this error by creating by passing this analyzer as an object that extends from our
‫implements.
‫The image analysis analyzer from the camera Android camera package.
‫How to solve it.
‫We will start in this video creating this class.
‫Okay.
‫So first of all, let me implement the image analysis.
‫Dot analyse l2 plus enter to implement the image that method.
‫Sorry, I need to implement the analyse only you can you can implement these three other or the other
‫three methods.
‫But I need to use the analysis method here.
‫I need to create two objects private
‫fragment manager and fragment manager.
‫Private Button
‫Dialog.
‫This is an instance from the bottom dialog that we have created.
‫So bottom dialog, this is an object from the class that we have created in the previous videos.
‫Classroom dialog.
‫Now.
‫The image analyzer.
‫Here, let me initialize this.
‫This data fragment or support fragment manager and button dialog equal new button dialog.
‫So whenever the user scan the barcode, it will create a new image analyzer object from this class and
‫start by creating it from the constructor here by initializing and a new button dialog.
‫So we need to create a new template.
‫I told you that this is this class acts as a template for every barcode scan.
‫Now analyze we use here scan scan bar code method.
‫What we need to pass we need to pass the image.
‫Okay, so this is the scan barcode method.
‫I will create it here.
‫Inside this plus create the method.
‫Scan barcode.
‫This is the scan barcode method that we are going to continue creating this and we need to create another
‫date, add another barcode reader method that is called reader barcode data.
‫Okay, so till now we have two methods to create.
‫I will continue now with the scan barcode and I will use.
‫At Suppress Suppress length.
‫The length is from the Android annotation.
‫Unsafe, unsafe.
‫Opt in usage error.
‫We are suppressing this error image image one equal image dot equal image dot get image plus enter to
‫import the package.
‫And now what we are going to make, we are going to assert we are going to check if image one does not
‫equal to null, then it will be searched.
‫Input image input image equal to input image from media image.
‫I will.
‫I need now to use the image one and I need to get the image info by using image dot.
‫Get image info
‫info dot.
‫Get a rotation degrees.
‫And now we are going to make the options for the barcode scanner.
‫Okay.
‫So what will what we have done to now we have created a new method called scan bar code inside that
‫image and my image analyzer class that implements the image analysis dot analyzer interface.
‫Then we have created an input image and stance and we have passed the image, one that we have created
‫under the unsafe option in user error, suppressing the length.
‫We will continue by the barcode barcode scanner.
‫This is from if we have heard.
‫This is from google.
‫The Android dot gm has amlc barcode scanning 18 .0.0, which is in that which is the library that we
‫have implemented in the in the beginning of this video at this chapter.
‫Now.
‫Scanner
‫scanner option equal to new bar code scanner options and dot builder dot set barcode format to barcode
‫QR code to a z tech.
‫So for bar code dot format, these are the formats of the the code, the bar code, so you can select
‫whatever you want.
‫But now I need the QR code.
‫You can add the many formats of the bar code.
‫Bar code dot format is at tech.
‫So you can add.
‫Your
‫your performance, your preferred performance.
‫Now barcode scanner scanner equal to barcode scanning
‫dot get client and I will pass the scanner options.
‫Task list of bar code
‫result.
‫I will I have created a task that took into the the the type of its generics as a list.
‫And this list is of bar code elements.
‫So I have created a list, bar code of bar codes and I passed them into the task that can do and scan
‫them in the previous in the background process.
‫What we need to process is the input image.
‫Add on successful listener new on successful success listener.
‫On success.
‫What we need to make is that the read bar code data.
‫So I will create a method called reader bar code
‫data.
‫Barcodes.
‫Plus enter create the reference inside the My Image Analysis analyzer.
‫Okay.
‫So these are the two methods.
‫They're either barcode data and the scan barcode that are implement that are created inside the My Image
‫Analyzer class.
‫Okay.
‫Now this is the success.
‫If the use if the the our app has had had read the barcode successful.
‫Now let's add the on failure lesson.
‫New on failure.
‫Listener And this is in case of failed to read the QR code.
‫What we will do.
‫We will create a new toast display to the user telling him that we have failed.
‫And three.
‫Third, we are going to add on complete lesson, your own complete lesson.
‫The complete listener here will be done in case everything, even if it's failed or it's a success,
‫succeeded.
‫We will make image.
‫Do not close.
‫We need to close the image and we close this method.
‫This is our method.
‫For reading.
‫The scan barcode.
‫Now, after we have scanned it, we need to use this scanning in order to get the data to analyze the
‫data stored inside the barcode.
‫So this is will be done in the next video by creating this method.