Learn how to create Android Apps with Android studio and Java | Maid Rondić | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learn how to create Android Apps with Android studio and Java

teacher avatar Maid Rondić, Professional Android developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

20 Lessons (2h 48m)
    • 1. Welcome to the Android course!

      1:15
    • 2. Installing Android Studio on Windows

      3:10
    • 3. Installing Android Studio on Mac

      3:04
    • 4. Getting familiar with Android studio and creating project

      13:43
    • 5. Creating Android virtual device and running the app on it

      6:59
    • 6. Running the app on your real device!

      2:31
    • 7. Button clicks in android

      10:13
    • 8. Getting user's input and confronting the app crashing

      18:00
    • 9. Styling UI and animating components

      16:57
    • 10. Navigating from one Activity to the other - Intents

      10:48
    • 11. Upload your app on Google Play Store or send it to someone without uploading

      7:50
    • 12. Saving state of something with Shared preferences - Switch component

      12:24
    • 13. Using Logs and Logcat for debugging purposes in Android

      9:36
    • 14. Android Activity Lifecycle

      13:57
    • 15. Playing video in Android app - Stream online video or play video from the device

      11:57
    • 16. Adding Launch (splash) screen

      8:48
    • 17. Android permissions and using Camera from our app

      17:15
    • 18. Make QR code scanner app - Part 1

      1:24
    • 19. Make QR code scanner app - Part 2

      13:19
    • 20. How to make your app fullscreen

      5:40
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

164

Students

--

Projects

About This Class

If you want to build your own Android Apps, either because you want to become an Android developer, to build App for yourself or you are just curious about it, this is the course for you.

We will get familiar with Android App development process. We will learn how to create your own Android applications by using Android studio integrated development environment as fast as possible. For the building apps we will use Java programming language. This course is designed for the beginners or people with no experience in Android development at all. Firstly we will download necessary software for Android development, then we will get familiar with Android studio and its environment. We will build a few apps where i will try to teach you many features/things in Android. 

You will learn how to generate apk file or apk bundle in order to upload your app to the google play store or  send your app to someone even though app is not uploaded to the google play store.

See you there!

Meet Your Teacher

Teacher Profile Image

Maid Rondić

Professional Android developer

Teacher

Hello, I'm Maid.

I am mobile and backend developer with Chemistry R&D background. Coding and puzzle solving geek. Passionate about learning and sharing knowledge in the best possible fashion!

I have experience in many different technologies, platforms and programming languages including java, kotlin, php, python and more.

i tend to create "straight to the point" courses and keep them boring as little as possible.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Welcome to the Android course!: Hey, thank you for showing interest in this android course. If you ever wanted to create your own enjoyed APs or you're just curious about how it's done, this is a great course for you. Here you will get familiar with Android Studio I D, which is used for creating enjoyed APS. We will create the app where I will demonstrate some android features and things so that you can implement them in your own app with your own ideas. This app, which is open right here, is just an example off what we're going to learn so we will learn how to customise buttons and the U I components in general. Then we will learn how to animate those components, and we'll also see how to create multiple pages in Android and how to transfer users input from one page to the another. So, for example, she typing something in here and we click on the button. We're getting that text in these second screen. We'll learn much, much more, and I keep adding content from time to time. So if you're interested, let's see you in the next video 2. Installing Android Studio on Windows: So before we get our hands dirty with the code, we firstly need to get software where we will be writing that code program where code gets written is called Idee. In general, that I d means integrated development environment, and in our case it will be Android Studio. So open your Web browser and search for Android studio and press the enter key on your keyboard. We will now open first link that comes up and we will get most recent version off Android Studio at the moment off. Recording this video, it's 4.0 you. The number that you are seeing is not 4.0. Don't worry, it will work mostly the same as this one, so you will be able tow. Follow the course without any problems. So let's go in a click on download. Interest to deal. Now we need to accept terms and conditions and let's start downloading. I have escaped downloading park, so now is the time to install Android Studio. So let's go and click on installation file here, click on next. Now you can see that android virtual device is checked here. That device is emulator or the mobile phone that we will be using for running application that we're going to build later on. You'll see also how to run the app on your riel device and how to download other virtual devices with different screen sizes and other configurations in order to test the app on multiple devices. So now we will leave this check box checked here on. That means that entered visual device will come installed with enjoyed studio so that we don't need to install it manually. Now go and click on next. No, you can truth destination folder. I will stick with this one on click on the stall Installation is completed, Soul is going next and let's click on finish with Start Andrew studio check box checked. Now you can see that under his studio is running on its opened. If you see the screen, it means that you have successfully installed entering studio. In the next video, we will get more familiar, which, under studio environment and we will create our first android project. So see you then 3. Installing Android Studio on Mac: Now we're going to download I. D or integrated development environment for Mac OS. So open your Web browser and typing Android Studio President Turkey Andi Click on first link that comes up Now you can see that most recent version at the moment of recording this video is 4.0. If you see some other number, don't you worry, because almost everything will be the same. You will be able to full of the course anyway, so just go and click on download. Now we need to accept terms and conditions on start downloading. I've skipped downloading part, so now let's go install. Enjoy studio click on the file that we have downloaded. No, simply just a drag enduring studio icon. Do these folder here so we can close this. Let's typing 100 Studio. So here it is, was going open it. It is verifying injury studio because this is the first time we are running it. Click on open Now. I have three options here because I have already used Android Studio on my computer. It asked me if I want to use settings from the previous one. I will not use it. I will just click on do not import settings. If this is the first time that you're installing injury studio, you will probably have only those two configure or installation folder and do not import statics so we'll choose. Do not import settings and click on OK, no go next will use standard And because I prefer darker colors are you choose this team over here. This can be changed later in the settings anyway. So go on Next I'm not click on finish I escaped installation part So now just click on finish And here it is. We have Android studio successfully opened. You are ready to start coding to see you in the next video. 4. Getting familiar with Android studio and creating project: it can happen. That color off Android studio might be white in your case, so let's see how to change Team Off Android studio Before we create new project. Click on Configure here. No choose settings and here select appearance and behavior. Now click on periods and for the team you can choose between these three. So if you choose, tell Ajay on click on apply. You can see that now colorful injury studio is white, and if you don't prefer white I d screen you can go back and switch it back to this one. I prefer Dr Cars, so I will stick to this one. So now let's see how to create new Andrew Studio Project. Firstly, we will click here and now you can see that we can choose for which platform we're building our app. We can choose for watches for TV, out of motive and similar. This will stick to the phone and tablet in discourse. Here we can basically choose which template we would like to use. So if we are about to create some application that uses Google location services, we could start this one or if we're building some app with Drover navigation. We can chew this one. But in 99% if not 100 we will start with empty activity because every one of these can be recreated from scratch and we will learn how to do it later in the course. So let's go and click next. Here we are specifying name off the application. So we will call this application first app now under the name of a vacation we see package name So what is back Ege name? Let's say that package name is something like unique. Identify off your app So if you applaud your app on Google play and later on you want to update your app it will know that you want toe update up If this package name is same as the one that is already on Google play so basically by package name Google play can differentiate between multiple applications on the play store convention Forgiving package names ease that we start with reverse domain. So in this case it's calm dark. Then you can write whatever you like, but avoid writing in example. So if we have example here, we couldn't upload this app to the Google plea because Google forbids that. Have example Word. Ian Beck. Youzhny. I would suggest you toe Seth. Package name com dot your name dot Name of the APP. No. Next we can choose location where our project will be stored so you can choose whichever you like. For the language, we will use java and then we're coming to the minimum as the K part so we can choose between android versions basically, And you we click Enjoyed? No, But it means that when we applaud these application on Google plea, this will mean that Onley devices that have android versions seven or above you can download our app or else they will get message which will say that your device is not supported by this app or something like that. So you can see that the higher android version we choose these percent number decreases. If we choose 10 for example, you can see that Onley 8.2% of the devices can run are up And that's because low number off devices have android 10. And if you we choose android kitkat, for example, you can see that 98.1% of the devices can download our app So now you wonder which difference will this make? Why, Why we even separate those? So there's because some devices don't have features that other do and simple example would be Step sensor step sensor is introduced right about give Katz version. So if we choose a P I 17 or Android jelly bean, we will not be able to use that sensor. We will go back to the android kids get and we will click on finish. You can see at the bottom that something is going on on that downloading and configuration building for our application. Most of the time, you will see something like this. Injury studio is preparing our project. Toby set up on toe make working correctly. So don't worry about the moment. Later on, you will see. What is that exactly? And why is that happening? So you should see those toe files open here. And in case you don't, you will open it like this. So go on the left side of hundreds studio click here and make sure that this android thing here is selected. Then open Java folder. Open this package here on open main activity. So main activities basically Java code with the logic off our app off our activity on Let's see what is activity, actually, so we will open now. Resource is folder open layout and open that other file, which is activity main. So it's basically something that user will see something do that user will be interacting with. Here we're designing user interface, and in this file here we are giving corresponding logic on users actions. So it's probably a lot for you to grasp at the moment, but it will become second nature to you. Trust me. Firstly, real focus on you. I design because it is probably simpler and more interesting for you at the moment. So let's minimize this part here, and this that used that, you see is probably terrifying for you as a beginner because it's really a lot to grasp. You can see all the kind of things everywhere. Let's start with the left side. Here. You can see that we have some components that are in common. Four Enjoyed up, for example, buttons to put button on the screen. You simply can drag it like this. You can put it here on Let's say, for example, that you want some image view to put you would chose this image view here. We will see later on how to do it with images. For now, let's put some tax to you. For example, Text View is pretty much label where you will display some information and now let's see right side off the enjoyed studio. So if you click on button, for example, you can see that this right side changed. If you click on text to you, you can also see that change happened. So basically, those are attributes for the view thes currently selected. So if we click on button, we cannot change how this button will look so we can go and find this text attribute. Here. Let's put in here some text and President Turkey. You can see that text have changed here Now, now what we can also do. We can change the color off the bottom background. So let's go scroll and find big round here. Now if we click here, you can write for example, some color we can use hashtagged 332211 hours Press and turkey. Now you can see that we have got some color in here Oh, let's go and change a little bit. Let's choose this one so you can see that big round is now changed. We have changed the color of the button and we can change multiple things here. For example, Alfa. It means how this button will be faded or not. So let's put 0.1 President Turkey. Now you can see that everything faded and there's because now this layout here is in focus , not the button. And let's was, firstly tried to change attribute of the button to be faded like this. Then where I will tell you what this constraint layout is. So let's undo this Alfa. Let's firstly click bottom so you can click. Either here or here is the same. No, let's find Alfa for the button here on. Let's put 0.2, for example, you can see that the bottom he is now almost transparent. So for the Alfa values, you use values from zero toe one. If you put one, does default value on, it means that component will be fully visible. Now let's see what is constraint. Layout is so that is basically ruutli out. That's something that holes or all of these components. Now you can see that those things that are surrounding this text view that already came. When we run our project, we call this constraint. It determines where are component will be placed inside this constraint layout. But you can see that button and text to you, which are added, don't have the don't have those constraints. And because of that, if you run this application now, both of these will be put in here because we didn't specify where it will be placed exactly on the screen. So let's undo this change by clicking weight control Z and let's add those constraint manually so you can simply click on this circle here and drag the top no click and bottom, and now was directed left. Now, when we already have some constraint Now you can drag this just by holding Click. By the way, constraint layout is one of the most complex layouts in Android, so it will be probably hard for you to understand and grasp this all at the beginning. So when we start building our app later on, we will use some simple or layouts, so that will be it for this video. In the next video, you will see how to finally run application on the emulator device 5. Creating Android virtual device and running the app on it: Okay, This is where we left last time. So now is the time to run our application on some device. So let's go and click on this play button here which say's around the app, and let's see what's going to happen. It say's that no targeted device is found. Soto, add the device. We need to click here an open, a weedy manager and now go and click on Create virtual device and here you can select whichever device you like, But I suggest you to pick one with play store integrated, so you need to have this mark here. I will choose pixel to, and you can choose whichever device you prefer. So let's go and click on next. Now we need to download version that we want to use on our device. So we have already downloaded enjoyed coup on. That's because we selected that's checkbooks before, when we were installing enjoyed studio, so you can just select coup proceed next. But if you have download text here next to the CU, it means that you firstly need to download that android version so you would just click on download and then you would proceed next so I will guide you now how to download Android by , for example so that you can know. So let's go click on download. You would accept terms and you will click on next. Now, when installing process is done, click on finish and now you can select by as well. But we will go with android coup. No going next here You can name your device however you like does the name that will be shown when we choose between devices that we want to run our upon, I will leave it as it is on click on finish and now we have our device ready for hosting the app. So now you can simply clothes the's dialogue and now you can see that we have our pixel device ready. And now if we click on play, this app will be executed inside our emulator device. Know where we'll wait until first time set up? He's done so it acts like the rial device we need to set up. We need to wait until everything gets ready. So now you can see that some error showed up in here and that's because our device wasn't ready for the app in time when APP was being installed on the device. So that was because first time we need to firstly wait for emulator to set up. But maybe you didn't get this error. So if it happens, just going click on plate once again and you can see that our app a successfully running. So now you have probably noticed that text view on our design preview is here. And when you run the app, it's located at the top left corner and as well you can see that we have here something which contains first app text which is the neighbor for our application. This part here he's called Action Bar or the toolbar. And we can see it in our design because we need to enable this show system. You? I think so. Once we enable it, we can now see toolbar and status bar. So this part here he's called status bar. So now about this text you here, what we click on it this year will be selected and you can see that we have some kind of error in here. You've recover over it Say's that this view is not constrained. It only has designed time positions, and it means that we have just put it in here. We didn't say where exactly it will be presented when the APP is running. So that's because those constraints that I was talking before the fastest way off, creating those constraints without dragging from circles to the parent or I didn't tell you before. But we can also constraint our view to some other view like this by way, every component inside Android Studio he is called a view because every single view, text view or button or image view extends class, which is called view. So we will call everything view that that will be generic name for components that we can put inside the screen. So let's get back to the track. So I was talking how toe easily set up constraints without us needing to drag from circles to the somewhere else. So just go and click on this thing here, which say's infer constraints. So now when we have clicked, it will automatically set up some constraints according to the view position inside the This design preview. So now let's go and run the app, and now you can see that are designed lochs exactly as the one in you I preview in the next video, we'll see how to run the application on the rial device. 6. Running the app on your real device!: Now we're going to learn how to run the application on the rial device to install the app from Android Studio to Reald device if you firstly, must enable developer mode on our device. So to enable developer mode, we need to do following things. So I will be showing that on this emulator and you will do it on your riel device so you need toe open settings. Then you need to find about here. It say's about emulated device. But I believe it's usually about the phone or about just then you need to find build number . If you can see it right away. It is probably inside softer informations or similar. When you find these build number, you need to click several times on it like so and now it's a Z. We are developer and Prego, Beck and open system and then on advanced. We see these developer options here and then we need to open these developer options and this USB debugging must be enabled like these on this device here. So once you do that, you need to plug in with USB. Cable your device to the computer. I did it now and you will probably need toe, allow access to phone data or you need to click to trust this PC or similar. So once you do that, now you can see that we have are really device up here. So you would just select your device and then you'll run the EP like you did on the emulator. So this is how you run the app on the rial device? Give it a try. And if there are any problems with anything, you can pose the questions and I will be happy to answer. So in the next video, we'll create new app and little finally see how to interact with the buttons and other views in enjoyed. So see you then. 7. Button clicks in android: now we'll create new android studio project. So firstly, we need to close this one and we will do it by clicking on file and then close project and we will click terminates to close our app on the emulator. So since the APP wasn't in the foreground, so it was already in the background. We didn't see anything on the emulator, but otherwise we would see that application would have closed. So now we're going to create new enjoyed studio project like related before. So click on it We will choose empty activity once again. And now we can name the like second app or so just click on finish. We will raise for grade all to finish building on and configuring it is done. So firstly, we will make some changes on D u I I didn't tell you. But behind every component that you've seen here, there is a cold to see that code behind. We can click on split so no, we can see the code off the u I, which is on the right and code is on left so we can see that once we click on this text to view this code in here is highlighted. So it means that this component here that is written in XML language defines this text view here so we can edit our views through the code as well. And once you get more advanced, you will be changing your components mostly through the XML code, because it is much more faster. Andi, there are less bugs than when you are doing it on you. I because it needs more time to render some things in this way, it is much more faster. So now I will show you how toe add a button with this code directly. So in the videos, before you have learned how we can just drag bottom from our component section to the u I. And now we're going to see how to create button from the XML coat so we'll just open tag and right button and press the enter key. Now we're specifying button with we can see 200 dp DP stays for the density pixel on for the height. Let's make it beat 70 dp Now we're just now we just need toe close detect like this. Now you are free to drag this button around in the U S section like this swell, and you could also do it with the code. In this case, it will be a bit harder, but we can just copy these things from the text to you. So those are constraints that we were talking about Before we will delete those, we would base this one. Now you can see that our button has the same position as the text of you to make it below the text to We'll add some margin toe the stop like this. We'll just start writing Stop and you can see that older the offered US margin top and we could say 200 dp or 150. You can see that the button is below toe. Put some name or text in here. We can just add attribute called text and press the enter key on right Click me like this. So now is the time to learn how to make some things happen once we click on these button. So here we have a tribute called own click. I will show you that we can also find it through these design. Here it is, right here on click. So here we are specifying method or function that will be triggered once we click the button. But firstly, we need to define that function inside main activity that Java file. So he rewriting Java code or the logic off are up to create methods in Java. We will do it like this. Well, right. Public voids on we will name it, show a toast message So this function or methods will be called show toast message Because we're going to show a toast message and you will see in a moment what toast message is for now. Just follow me. So toast message is created in this way. We write toast dot make text. Then we are specifying context in here. So context. He's a bit more difficult to understand as a beginner, but basically it defines context off the applications. Current state or just it defines context where something will be executed. So if we see main activity dot this it means that the message that we are going to show will be displayed on main activity or on this layout here. So when the user is currently in main activity, this message will be displayed right there. So now we're going to ride the message button clicked. Now we need comma and we're specifying here duration, which can be long or short. So let's put a short one and add semicolon. So don't worry about this context just yet. You can learn about it later, so this is highlighted and it stays that we have probably forgotten to call show and I d is correct. We need Toe added that show in here to make this those message appear. Now we need toe ad. This method will be creators. It means that barometer of this method is some kind of view. And basically we are passing that view once we choose here this method like this, so it already offer us to choose show toast message. And if we remove this parameter, you could see that it doesn't offer us anything because it can't recognize that there are any methods that can be called on this button. Click. So there's because we need toe pass a view here so that I d can know that we are going to do something with this matter, that when view is pressed so now we can select it like this. And now, in code section. You can see that this attributed is added automatic Ili because every change in here or in here will be reflected in both places, and you can see that the great color turned into the yellow one. Which means that this method is used somewhere. Now is the time to run the up to test if it works, if we click, you can see that those message appears. So that is a toast message. This balloon that shows up and disappears in the next video. We're going to do more manipulations with the view with clicks, and we will try to get the user's input and do some things with it, So see you in the next video. 8. Getting user's input and confronting the app crashing: in this video, we will see how to get users input and do something with it. So go on open activity. Underscore main dot xml file. We can switch to the design if you feel it easier and for the getting inputs we're using edit text or the input fields So we can click on these text instead of common to search for it or toe find it easier. And it is plain text, so they're changing its name from time to time. But before it was called edit text. If you drag it in here like this and open D code part, you can see that it's called edit text in here. Still, so it doesn't matter how you call it, So let's position it somewhere like here, for example, on we will constraint it, Toby. Here we can change its with like this, and we can add one more input. So we will try to get two numbers from the user and we will multiply them on. The result will be shown instead of these hello world text. So this is the plan. Now when we click on this one, we can go in this section in here and we can delete this name. Press the enter key. So now it's empty, but we will add hint. So here we will. Right. Enter a number and presenter so you can see that it can't feet very well. So will expand this a little bit so he text will be automatically removed. Once the user start putting some things in here, we will do the same for this one. Well, right. Enter second number. We can also we will expend these one a swell. And now now is the part when we are getting the input from the user. So how we do it, you can see that when we click some of these here, we can see this I d and we will use this I d to do something with certain with the corresponding component within Java code. So let's change this idea, Toby. Number one, president or keep And for Did this one? Let's see, Number two, President Ricky. So now we need to declare those edit text in here like this l a text and we will see number one comma number two and you can see these on create method. So this method is called first when our app runs or where when this main activity gets opened so you can see that firstly, it sets content view and it means that it touches this you I to the these Java code. So the Java code actually shows this you I to the user with this said content you now inside this on create we need to initialize are ready texts and we're doing it like this We will refer to the number one first and we will say equal find view by I d and I d is something that we have specified in here. So that's why we need i d toe inst a shade the object from the u r. And now we're here specifying are dot i d dot number one are that i d. It probably stays for the resource is start I d. So that is our And now we will do the same for the number two If you press the control, the or command If you're using Mac, you can duplicate a code many times so we will do it just one more time to make this easier . Instead of number one, we're now getting number two and for D Object name were also now referring to the number two. So once the user clicks on the button, this method will be executed. But now we will call this method, multiply the number, or let's say, let's firstly just show those numbers in this toast message and later we will do the multiplication part. So, firstly, let's get that first number. Every input well, firstly get as a strength and later we can convert it to anything we want. So I will say string first number equals number one dot get text. So these get text returns creditable object, and we need to convert it to the string. So now we got our first number, and we will do the same for the second. And here no, well, say number two. So once we click on the button, we will fetch the values that user have put in the edit text. Then, in this toast message, well, simply display those two first number. We will separate them. Second number. Let's run the app and see what's going to happen. So let's input this number here. Let's input something like this and click on the button now you can see that numbers are show so you can see that we can even delete the number and click and how empty string will be show like this. So that's something that you you can prevent. For example, you can see that those message will not appear. If user didn't import any number. Now you can see that will be clicking here. We can input even text to force user to input on Lee numbers. We can change input, type off those plain texts or edit text if you will. So inputs type. Click on this flag here and we will select number decimal and apply. We will do the same for this one. If we run the up again, let's see what's going to happen. You can see no that only numbers are displayed. Now is the time to multiply those two numbers on to show the result instead of these hello world text. So let's go back to the code. Firstly, we need toe declare that text view like we did for the edit text, so every component that we want to be modified in some way needs to be declared on initialized in Java code. Firstly, text view. Let's say result and now we need to add some I D to it. Result spent. We have done it. No, we need toe converted those strings to the integer numbers and show them as the result or and show multiplication result. In that text you from my will will declare integer result equals integer dot parse int first number So this is how we convert string to the integer number in Java Multiply the by inter jered out parts int number two and then Or you can see that it's showing us an error because we referred to the number toe added text and not to the second number. So convention is basically that editor text should start with e d d and then something so that we can differentiate it much more better in our coat. But I did it in this way so that you can find it easier. Maybe, but later on, we will always use evd before words like this. And when we want toe refer to detects for you will use txt Also, we would do that for the i d. So for now, let's make it stay this way. Now let's show the result in here. So we will add it Message like this. Well, it's run Dia. If we put some numbers on click, it shows the result. But to put this result in the text of you, we need to refer to this result next to you dot set text and result number. But we need to use string values when it comes to the presenting set text in the text you method or else it will cause our act crash. So we will firstly need to convert this to the ST dot value off result number. So this is the way we convert numbers to the strings. So let's run the up now and let's say 40 on three. If you click, we can see the result in here. If we here put zero, we got zero. No, let's editor call to make it more readable. So we need to re factor this name. So if we put in here et, you can see that errors are showing on multiple places. But we can do something toe edit all the references at once so you can use right click on re factor and Rini and you can hear put DDT and put the capital and and press the enter key so all of the references will be changed. You can see we will do the same for the number two and text view. You can do it also by holding shift and F six on the keyboard and in here a swell txt result. So now it's much more readable. So here we earn So here we now that we're referring to the Eddie text and here to the text result. So let's see what's going to happen if we omit input in some of the edit text like this. If we click now, our APP is going to crash. And when the APP crashes to find out the reason we're using Lockett. So look at holds information about our application and system in general, so we will choose error instead off verbals to find out the reason off our crash. When you're looking for the crash, try toe firstly, see some blue text like this and then go up and this is the reason. So it's a is that couldn't execute method on click and that matter. There was this one because it say's that java dot long number for Mitt Exception for the input string. And it say's that ever happens on this line in here when you click on this blue text. So it means, basically that it couldn't convert empty string to the integer, and that's why exception happened. So to prevent these crushing, we can put some if statements to determine whether the input off the user was correct or not. So here, before converting those strings through the numbers, we could see if first number he's empty, which means that user didn't input anything or second number is empty. We will display toast message that we'll see wrong input and we will return, which will prevent executing code from here to the bottom so that these error can't happen . Let's run the app and check what's going on. If we know armistice input here and just put here nine or 99 for example, and click it say's that it's wrong input so we can do like this, and if we make correct input and click, it will execute this part below. So in the next video, we'll learn a bit about animations in Android. So once we click on the button we will see how toe rotate something's or how to translate it from the one position to the other. We'll also learn how to make those components a bit prettier, so we will add some styling and shaping to it. So see you in the next video. 9. Styling UI and animating components: Hello, everyone. Now is the time to create new project and we will learn how to use custom shapes in order to make our you I design more beautiful. Choose empty activity. Let's name this you, I thinks and finish. So we have lay out in here if you wonder how to change this route layout So as you can see , whatever we drag, it must be inside this route layout. And if we try to delete this layout, we can't. Nothing happens, actually. So let's introduced linearly out for a difference to change these constraint layout linearly out. We must select all of these. I'm just start typing Linear Leo. So once we have changed these to the linear layouts, those four attributes are useless because they only work if we are in constraint layout. There are two types awfully nearly out. One is vertical and the other is horizontal. So if we copy this text of you and we add another one, we can see that there next to the each other. If we add one more, it will be also next to this one because by default, linear layout is horizontal and to change it toe vertical we use orientation attributes and we just chose vertical like this. So now you can also notice that we can't drug these items around because we're not in constraint layout anymore. We are in layout, which puts its content linearly next to each other in some way. So if you want to put those tree in center, for example, we could use gravity attributes. So layout gravity center means that this item in here I will be moved to the center. We can do that 40 for the rest off those. But we can also just use gravity attribute in this parent layout like so. So you you can notice that we're using gravity here, but we have also clay out gravity attributes like this. So difference is that gravity layout describes where the content off this layout will be put. So it means it Basically, the term is where those three will be put. And if we use layout gravity, it means where these text view itself. Where will be positioned if we put here left, it moves to the left. You can see it will not fall of the orders off the parent layout so you can see that we have warnings which say's you start instead off left And that's because if we expect our users Toby from the regions where our right to left languages supported If we say start in their case, this will not be at this left side. It will be at the right side so it will basically act from the start where certain language starts. We will know Delete this layout gravity Believe it like this on Let's let's now increased size off those text use to the 20 dp Like this base the spell you in here and to you you can notice highlighted text size which say's should use us be instead of DP for text sizes on. If we change these dp to the SP Nothing changes here, but warning disappears. So what is the difference between S B and V P? Let's imagine that our thanks to you is dp for a moment. And if the user goes in the end road system settings on their device on chooses toe. In general text appearance is big because maybe the user can see very well on. They choose text to be bigger in general. If our text you value is in DP that settings will not affect our app, so text will be just as we see it right now. And if if our text is SP, it means that it will be increased accordingly to the user's settings. So that's the difference if the user chooses their text to be less size, this text size will also be corrected from 20 to some a little bit lower value. Now let's add a button to the sleigh out like this on Let's both values off the with Toby 115 b and for the height, 70 dp for the text inside, let's put bottom. You can see that even though we have put bottom like this, all letters are capitalizing here. And that's because we need to turn off text all caps attributes to false. So by default. It's true for the buttons, so every word will be out of capitalized. Now, when this false it will be here as we type in here. Now is the time to make our button custom, so it is default. You can see it's a bit ugly, so to change its background, we can use background attribute. We can put some color like this, but still you can see that it's ordinary rectangle. And that was the question. How to make this button rounded. So to make it around it, we need to create new drivable file and we will expand This resource is folder and then drove away and right Click on Drop Verbal and the new Drug Bill Resource File and we will name it Ground Big Round, for example. President. No, let's change these selector to the shape and in here inside let's corners and attribute Radius will be 11 b p. We will close the stag, but not in this way. Well, the self closing time Because we don't need that one, it would be the same. But it is more simple this way. No, we need to add solid color, Toby this one, for example. And if we now go back and forth this button background, we used the file that we have just created. You can see how the button looks like. Now we can also make some Grady and color in here instead of solid, we can say radiant. And now we have attributes which are start color. We will use this primary dark on for the end color. We will use this one, so I need to close attack and we go back. We can see much difference because off the color choice. But if we use color accent now, it is noticeable. Let's at the top emerging here like this we can you reuse these background for the text views as well? So if you just add attribute background to be ground backgrounds, look how the text of you will we'll be now. You can make separate files for the text view separate for the bottle if you want them to be different. Now let's see how to make some animations. So, firstly, let's go in Java code and create a method which will be triggered when we click the button . So we will use public voice animate well, best view parameter, and we no need to declare those components that we want to in to react to it. So let's declare text you and we need to now set some I D for detects to you. We will use this in with this one in the middle in purpose, off animating the extent door. What's called called this idea like that now we need to initialize it. Txt two like so, and we need toe put on click attributes for this button. Toby. Any made metal from the main activity? So now is the time to learn how to animate these text to you. So once we click the button, we want this text view. Toby rotated, so we'll do it in this way. Text view dot animate dot rotation Here we can choose on which access it will make rotations, and we have here metals with this word by at the end and one without. So if we use by values, it will rotate the item from the current position by some degree. For example, if we now put 220 and we say start once we click the button, let's see what's going to happen. You can see how we eat, rotated by 120 if we use one time second time and third time, it made 360 degrees and it's back to normal. But if we use rotation X and run the it irritated itself by 120. But if we click more times, nothing will happen because This text view is rotated once by 1 120 every time we click, it will try to rotate this text view by 120 from the starting position. And starting position is the one where this button is normal. And if we see by 120 every time we click, it will do the animation from that current state. So there's a difference. No, let's change these to the rotation. Now it will rotate itself cloak twice. I believe. What you can also use this apply changes instead of running up. When we're doing some small changes in our code, we can use this one to prevent closing and opening our app every time. So changes are applied every click on button. We can see how it rotates now. If we add by, we will also achieve that effect. When every time we click, it will move itself. No, let's see more animations. We can also make our items disappear. For example, if we say Alfa 20 on, we say starts. When we click on this button, this one disappears. We can also set duration to make it more beautiful. So let's set it toe 1.5 2nd So we're using milliseconds value in the brackets. If we click now, you can see how it delays how it it looks nicely. So we have many, many animations features, but we will will check one or two more. So one interesting is kale. So we will use kale scale. Why? To the 1.2 and we will also scale x 1.2. Will saturation toe half second and start. So you're its eggs that we need floating values and idea recognize double value. So we will just add f word like So So it's float value. So 1.2 means that DVD vite off the item was 100 BP, for example. After scaling toe 1.2, it will be 120 so simple as that. Let's no see that in practice we click. You can see how it got bigger and then disappeared. So we will comment out this one. By the way, we're commenting our code by holding control on and slash toe out a comment The line where we are currently. So now you can see how it got scaled like this one more is also interesting on it is translating so we can move the item on the screen by some value. Let's see how it is works. So it got translated to this position. And if we have used by value, you could you would see that every time we click items would be moved for the 300 pixels in the right or 300 density pixels. Actually. So this is for the U I animations on the customization. In the next one we will learn how toe create new Beijing android. So as you can see, we're only using this one screen and we will learn now how toe get transferred from this page in android app to the some other page. So see you in the next video. 10. Navigating from one Activity to the other - Intents : So far we have been using Onley This one activity, this one screen. So now is the time to learn how to create another activity or the another screen where user can go from this one. And in this lecture we will learn that. So for that we need to create new activity and to create new activity. We need to right click on this job a folder, you'll and activity. Now this here might be familiar to you because when we are creating new project, we are also prompted with those activity models that we can choose. So now we will choose empty activity like we did when we created project. We will no name the activity as second activity Anglican finish. So now we have to activities when his main activity and this one is second activity and lay out for the second activities Empty as you can see, it's not is the question how toe transfer the user from main activity to this one. So for doing that, we're using something called intense, intense our object that are used for transferring user from one activity to another. We will see that in a moment. First there. Let's create new method that will be cold. Go to the second, give it to you. No. We will create intent objects. We will call it intent. It is equal to the new intern. Now, Inside the brackets, we're specifying from which activity we are going Where? So since we are in main activity we are specifying main activity dot this comma and we want to go to the second activity dot class And now we need to start activity and we're doing it by calling start activity. And we need to pass this intern object which will tell the system. Where are we going now? We will do it real trigger this method also where we click this button here. So, after triggering those animations, we will call go to the second activity. Now let's test how it works. If we click, we're now at the second activity, which is empty. Now if you wonder how the android knows which activity to present first. So how it how we did it know that we are going toe lounge main activity Firstly And then we will go to the second activity on button click. How? What? Why? Second activities not run first. Well, for that we have manifest file and it is here under duplication. You can find it so you can expand it and open this or double click on these folder. Here are stored information about our app. So here are declared all the activities that our app have and many other things which are more complex. So I will not discuss about them in the moment. Firstly, you see these application Tuck and here we are having icon So basically, when the user installs our app they will have this icon on the screen. This is how our app will be named. This is how our up well look on the devices death are requiring that are presenting rounding I Come on, this is team far app So it is something for a different topic. So Aro skip that for now and then we have activities. So here is our second activity and this is main activity. This in turn field her with these category main and launcher tells the android system that this activity should start first when our app is opened. So if we move, this ain't and skilled her between those two attacks And if you run the up, Let's he was going to happen. So now we have the second activity started. First, let's go back to decode. We will know change our second activity. I will add a text of you and we will give it an I d. Txt second. Now we will put some text like this. Well, let's change this constraint layout to the we nearly out on Let's said the layout gravity centered. If you wonder why these text is now center the but left instead of here. That's because by default, linear layout is horizontal. So if you change orientation to the vertical, our text will be centered right here. If you want tax Toby here, then we must specify gravity in this. We nearly out through the center. So that's how it works. Now we want toe update this text from the value that will be input from the user on main activity. So let's see how to achieve that. Firstly, we will add some added text in here so that user can give us some in books. Now let's find plain text like here on let's give it some I D e. D input. Now we need to declare and initialize that Eddie Text PDT input. And when we click on the button, we want to fetch the input from this Eddie text and transfer it to the second activity. So we're doing it with help off these intent objects to put something in this entered object we're using put extra method and firstly, we are specifying key. It will be some input. And that's the key that we will use in our second activity together. True value that user have put in here on the value will be any tax. Don't get text not to string. So once we click on that bottom, we will go to the second activity on import that was inside. This added text will be transferred in here. So the fetch that input in here we need toe get intent. So we're now getting intent from before and we're now saying get string extra because we want to get stream value. We have also some other methods get in Textor a double float or except through. But we will use string extra No, we will use that key from Lee previous activity and we will store death into the string variable like So Now we need to initialize this text view because we want toe up the text as soon as we get transition in here. Okay, So does the I D. And then simply said text some input. No, let's run the up now. We will se on. If we click on these button, we can see that texting here also, if we don't say anything, we have empty string in here. Now you have learned how to make new activity and how to transition from one activity to the other. So that's it for now. I hope that you have learned a lot things that you can use for your own app and expect more videos in the scores. I will be adding them from time to time. We will learn some more advanced things later on. So is to you 11. Upload your app on Google Play Store or send it to someone without uploading: Hey, everyone in this video, I want to show you how to generate a PK file off your app So this file can be used later for sharing forgiving your app to your friends, for example. And they can be stole your app even though your app is not on Google play, so to generate a p k file off your project. So this is some project. It doesn't matter which one you would open your project and go on built. Then you would go on this build bundle a p k, and you would then click on this build a PK and once you do it, wait for the android studio to generate that a p k file so that hbk file can be sent someone. And if that person wants to install the app from that a p K file that you sent to them, they first need to enable or to turn on installing APS from untrusted sources. So now a PK is generated on. You would click on this locate right there and now. Now it took us to the folder where a B K file degenerated. So there's the one right here. So if you would like someone to install the app that you have just created. You have generated the A P K file like I just showed you, So you would just copy this a p K. And you could send it through the email or however you want. But as I mentioned that person that would receive your A P K file in order to install that app, they firstly must enable downloading or, let's say, installing APS from untrusted sources. To do that, you would probably need to enable that option in configuration off privacy settings. I believe so. It's different on different devices, but in general it's about security on privacy settings. So somewhere there you would need to enable it, and after that, you can easily install these app. So now what? If you want to applaud your app on Google play, you would then go on build and you then generate signed bundle A PK. So let's go and click What's going to happen? Let's see. So here you can choose between bundle or a PK if you choose bundle. It says that there are some convenience in here and benefits our app would take up less space and this is the probably best option when it comes to the applauding your app to the Google play. Because if you go on this android that bundle you need, though much less things than if you choose a PK. So let's stick to these android app a bundle, then go next. Here, you need to specify where your key will be stored. So this is some kind off virtual signing. It's approved this this is our up. So we're signing it basically like when you sign some paper so you would hear Choose destination where that key will be stored so you can choose whichever folder you would like . Let's say like this this week on a K. We need to specify password, so we will specify something we need to specify password in here. A swell. Well, now we need to fulfill some of those, but I believe that some of those are optional. So let's try with this. So we Twerk smell is go on next and here. We need to sign this with release build variant. So release is when you want to upload your up to the Google and the bug is D one that we are working on. So when you decide toe, publish your app on Google play, you choose release or else it won't be accepted by the Google. Now, when you click on finish, we need to wait until this bundle gets generated. Okay, so let's expand this and located only to locate this, actually, and we have this file with Extension A A B, and that is something like application bundle. Soto applaud these bundle to the Google play. We need to use Google Play Council and I already have this enabled and everything. By the way, you need toe pay $25 or euros, I forgot. If you want to have a Google play developer account only that you would be able to publish your app on Google play. So once you open your Google Play Council, you will be prompted to eat something like this. Then you would go on, create application here, you specify some name. I would just taping something random you would go and create and then, after all of those settings, so you would need to input some preview images, categories, all different kind of data. Then you would need to click on a polices. And somewhere there you will go on this production. Manage. And when you click on create release, you would upload. Did that bundle in here? So this is great out because we didn't fulfill any of those requirements. So those are great out. You can see when you do that, this will be enabled. And you could upload your app to the Google play store. I hope that you have learned a lot on this is very easy toe. Do so on Lee. Follow the steps and there are no mistakes whatsoever. So let's see you in the next video. 12. Saving state of something with Shared preferences - Switch component: Hey, everyone, in this video, we're gonna learn about shared preferences on. This is a very good opportunity to introduce switch view component in Android as well. I have opened, enjoyed studio and created one empty project called Shared Preferences on. I'm gonna open it Now. You already know how to create New Android Project. I believe so. So let's firstly, at that switch view component and let's see how how it looks like so you can find it right there. And if you can't, you can simply surgeon here for the switch, so let's a drag it in here. Let's constraint it by using this this component here. So when you click it, you can add constraints automatically according to the view current position. You can already guess that's which is used for turning on or off something. So let's imagine that we have notifications in our app and let's imagine that user wants to turn the notifications off. So how can we do it? We would use some switch components somewhere we would put it, and let's change the name to the unification. Like so, and when the user turns off or turns on the notification, we must somehow remember what was the user's choice. So let's see how it works. Now if we run the app No, these switch came turned off. If we turn it on and we close our app like this and now we open it again, you can see that this which is once again turned off even though we left it turned on when we close our app. So now is the question. How to save these notification turned on for that purpose. We use shared preferences. So, like the name say's it's about preferences or the settings that user have set. No, let's see how to use it. So we're first Well, first to declare the switch components we will call. It's like this Now we will initialize it like so So this was the i. D off the component. And no, we need to set on that switch changed listener so that we know that user switched on or switched off notifications. So let's set that listener like this set on checked change listener. Now let's say new and you can start typing checked and we will choose this one like this. So this is called anonymous inner class in general. So it's maybe a bit more advanced feature in Java, so don't bother too much about it. For now, you only need to know that we can set listeners, Let's see on a fly. So I'm now changing the subject. But I need to I need to tell you that we can set on click listeners in this way as well. So in previous videos you have learned that for the click listeners or actions that we want to do when some views clicked, we would go and find did there on click attribute, and we would their ad matter that will be triggered once the view gets clicked. But we can do it also in this way. So let's now set on Click Listener for these notes vacation so we can do it like this. So now we don't need to use on click attribute here. We can hear call any matter that we want to be executed when the view is clicked. So now I did the same for this on Chek Change listener. So now when we click on the switch like this and when these gets turned on or the off we will trigger something inside here. So we will get bullion, which will tell us Is the switch checked or not? So is it on or is it off? So we will check that in if statement we will say if B it means that he's checked. Do something about it so we'll hear. Save that user turned on notifications on Dhere. If it returns false, we will say that notifications are turned off so we need to save that in our preferences. So let's see how we do it. Well, firstly, here declare shared preferences object and we will call it shared references. Now in on create method, we real initialize it like this. So we need preference CES manager this one and we need to say get default shared preferences and for the context we will use this so main activity will be the context And in here we're gonna save our preferences. That's notification is turned on so we will refer to the shared preferences and we will now say edit dot put bullion So we will now hear use some key and value key will be notifications and value is true. So this means notifications are enabled, for example and we need to also commit or applied this change. So there is a difference between apply and commit. So if we say commit, it means that it will be stored in our preferences in this exact moment. And if we say apply, it will get saved on a different thread. So this is also one more advanced topic that I will not bother you for now, but you can choose whichever you would like. So if we put Comet, you can see that there is a warning which tell us, consider using apply and hear his explanation. So apply will handle this in background, which means that our application you I will not be freezed or it will not lag. So we will use apply to use that background task to save these preference. And here we will say that notifications are off so he will put false. So now in general, what is shared preference. So it's some kind of object where we can store some values. But this is not like database. We assured preferences. We can Onley store value which is bullion which is a single string value some integer number or so so it is used for small tasks for saving small data, something that we don't need database for. And now when we run our app, we want toe get our notifications which switched on or off according to the user's preference. So we want to save what the user have done and we will do it when the app opens. So how to do it? How to get this value, how to get identifications are checked or not. So we will do it here. When the APP runs, we will get shared preferences object and we will now say get Boolean notifications. And now here we must specify some default value and here we must specify some default value . So when the user firstly runs our app, it will not have these fared preference. So we clue it will never be put because the user is running are up first time. So in that case we will say true. So by default we want our notifications to be enabled, so bay So basically, if these methods doesn't find notifications between the keys inside our shared preference, it will return true and it does. It will return what the user has stored last time, so we will save this in some bullion value and we will call it is Notify Dirndl and now we'll use this statement which will check even the notifications are turned on. We want toe are sweet Notifications make checked So we'll say, said checked. True or basically we don't need. We don't even need this. If statement we can simply say notification said checked. Is notification turned on? So if this matter, the returns falls we will make it unchecked And if it returns true, it will be checked. So if you run the app now we are expecting this switch to be checked on because by default we said notifications are turned on so you can see that it is turned on. Now if we switch it off and now we close the app on open it it knows that notifications are turned off because in here we have put that in the preferences. So let's do it once again. Now we will leave it checked and we free closed the app and open it again. It will be checked. So that's about shed preferences and switch view component in Android. And I'm seeing you in the next video 13. Using Logs and Logcat for debugging purposes in Android: Hey there. In this video, we're gonna talk about log cat logging and android activity. Life cycle. So first of all, let's create new Android Project. I will name it Life Cycle. I've skipped Grateful Building Part. So firstly, we're gonna talk about luck Kit and the log class you have probably seen Look at at the bottom of the android studio. So here we have some kind of data, some kind of information about our application or some other application. So why do we use that if some kind of error occurs? We have exact information in the locket. Why that happened? It is most useful when it comes to the app crashing. So, no, I will show you how to write our own log that will be displayed in here. So we're doing it by typing in log dot de. And now we are firstly specifying tag. You'll see in a moment why do we need that attack? So I will call it some tag, then come and then we can put some tree string here which will describe something so no, I will see on create method called since we are already inside these on create method So once these on create method to get string erred, we will get this output message in our lock it So I will know on purpose select error and I will run the app to see what's going to happen. So now are happy is up and running. Now you can see some error here and that her that error is type of the error that we can do anything about simply. There are always going to be some kind of errors, memory leaks or similar that we simply can't effect on. So these tag in here is used for filtering out Put in here. If we had 1000 errors in here, for example, we would use this tag to distinguish our luck our own look. So if we type in some tag, you can see that nothing is showing up in here. And that's because here is error selected. And this kind of flog is not error log. It is debug. Look, that's why we said that D So we will switch this three d buck and now you can see that we got our own look. So if we start deleting from the stag, you can see that more and more logs our show so you can see now how hard would be to find our log. So if you just type our tag, we would find it easily. But now we can't find it either this because, uh, when it comes to the multiple logs in here, we're talking about multiple thousands off lines. Some lines that were on the top simply are deleted because off memory reasons, so it couldn't store infinite number off logs. Now, why is this important to us? Why do we use those locks? So, for example, if we have a four loop in here, let's say and let's say that we want to do some action multiple times, for example, nine. Now, if you want to keep track off this for hope somehow without interrupting our own app. So we just want to see how it goes in this council in here. Maybe if we have some kind of bug on, we can determine where the Baggies we would simply put a log in here and we would say, Let's say, for example, for look output and let's bring it out. This I now we will get an error because look, it must output stream values, so we will just do it like this in order to convert it to this drink. Now, if we run the app, we need to change tack to the four look output. And when the APA gets run, we can see here. That lug gave us nine outputs. So this is very good, because we sometimes maybe in our application, sometimes some button doesn't work. If we click it simply, nothing happens. Then we could try with logs to determine what the problem could be. So let's imagine that we have some kind off button. Let's call it BTM. And if we have some matters that we want to be triggered when we click the button Bt and clicked, let's call it like that. And let's put the view is an argument. Andi, when we click our button, we want to change these stacks to something else. So for that, we need to declare our button first on. We need to initialize it. So once we click this, we want to set text off these buttons to the changed. Now, if we run the and we click on this button and we see that nothing happens. We can now use log to determine if this button click even works. So we could simply put it in this method here and we can say button is clicked and we run d up. And if we click now, you can see that there is no output, which means that these bats and click isn't maybe even set. So we didn't tell the button which mattered to trigger once it gets clicked. So now you may be wonder. It's obvious that we didn't do it, since this text didn't change to the word that we specified here. But imagine that we have here. But imagine that we had here some complex calculations or fetching from the Internet. So we couldn't that easily determine whether this method even gets cold or not. So now, if we set these method as own click attribute and we repeat the click now we need to change this with these d buck to the some tag and you can see that it gets called it. We can see button is clicked in our council. This video is getting a little bit longer than expected. So we're going to continue in the next one with the android activity lifecycle. So see you there 14. Android Activity Lifecycle: This is very stopped in a previous video. So now we need to talk about android activity. Life cycle. So what is that? So basically life cycle is something through our activity goes from the moment it gets created until it gets destroyed. You have already seen these on create method in here. So this is the first metal off that life cycle. When we lounge our activity now main activities launches, you can see first metals that gots created by android framework itself is on create matter After that method called on start will be called so we can override that matter. They're swell after own start method we have on the resume method. Later on, I will explain you each and why we used them. Now when we destroy our activity, when we go back or when we lounge some other activity first matter that gonna be called ease on posts after impose on stop will be called. And finally, we have own destroy. So once we're finished with our activity on destroys last cold. So firstly, I'm gonna put the logs inside each of these methods so that we can see exact order off calling. Now. I will change tag off this method to be my luck. And I relieve it like it is on. Create. Um I forgot to tell you that we can change this character toe w. And it means that this log is warning log and we would find it here by selecting war. Now you can see that we can choose between all of these on for each of those we would change respectively letter. So if we choose E, it means that error log will be show. So now we want to just show the bug because we just want to see how something works. This is not any kind of error. Now, I will copy this one and paste it in here. But this time I will change this study on start here I will set to the own assume here. Bulls on stop and on destroy. No, it's going lounge to the app and change this to the debug and my look. No filter. Now you see that first method that was called the zone create than on start and own resume . But you can see here that they're pretty close to each other. So they almost launched. They almost got called in exact same moment. And that's because we're not doing any extensive task we teen. So in on create matter were Onley initializing one view and we're setting content so that will be kept that will be done in less than a second later on start and resume their doing almost nothing but bringing out this. Look, if we had some extensive task which would do some, I don't know, network fetching some other things, we would see a better difference. So now if we press this button here on the emulator, you can see that impose meant of these cold and then on stop. So on pose is called once our app is not in the primary focus anymore. So if we do something like this, if we leave our app like so so it is still in the background. But we're not seeing this activity anymore. And if we open it again now, you can see that on start is called and on the resume were missing on creating here. And that's because on destroy wasn't called, So our activity wasn't destroyed, so there is no need to recreate it again. If we press this button here to go back then on destroy method will be called last. So now if we open our app again on create will be called. And so for now, why we use those methods on create matter is basically used for initializing objects that will be used later for setting layout and similar on start matters is used in some cases when we want to register some kind off listener. If, for example, we want to make the app that will work with sensors, we will do it later in this course for sure. But for now, you need to know that every sensor that are android phone possessed, he has listeners or the methods that hard that gets triggered when some change in sensor occurs. So let's imagine proximity sensor. It's the sounds are that is located somewhere in here, where I'm pointing at the moment and it is used, you know, when you call someone on Viber or what's up or even regular phone cold. And when you put the phone near to the something, or near to your to your ear, the screen goes dark so it turns off the screen. And that's because proximity sensor I got notified about something. Some object is getting closer to the device. So we would register that listener in on start matters in here and in on pause method or on stop method. We would unregistered that listener because we don't need toe burn our battery down since we don't need to use that sense or anymore. So if we don't unregistered the sensor, it will be working in the background. Even we close our app and we don't want to do it. No. Sometimes on post can be called without on stop metal after it. And if we, for example, I will put some more space in here, you're free. For example. Just turn off the screen and our device have enough memory not to call and stop mattered. So now you saw that on stopping anyway called. But on stop usually gets called when when our system gets low on memory. So it would really something toe expanded memory but in 90% 99 percent of the time they will be called both on pose and on stop method. So on a resume method is called. Once we see the you are displayed so in exact moment when this interface of the application that we're using is shown tow us on resume method gets called. So it's a perfect opportunity toe show some notification to the user, some alert, some message. For example. Welcome to the APP or something like that. We could do it in on create and don't start, of course. But in UN resume it would be much better because, uh, on creating on start have finished their job and last on destroy method was called one of our activities and destroyed. So when we simply go back or if we open some new activity and our app on our android system get slow on memory so it would destroy previous activity because I don't know, system is full off some kind off Rahman ram. Memory of the system is full for some reason. So basically, if we now open some other activity on destroy will not be called. But sometimes later, if we don't use this activity for a longer time, we're only doing some things in different activities. It will be destroyed automatically. Now, if you wonder how we can call on destroy manually how we can tell the app to destroy the activity, so we would simply call mattered named finish. So, for example, if we put this method in on creating it of, like this and if we run the app, what see was going to happen? So on Lee on create an on destroy method was called So are up skipped those four. And if we call this finish in one start or in on resume, let's he was going to happen now, Now you see that we Anyway, so on start on, stop and on destroy. So we didn't skip on pose and on stop. We can only these we have only escaped on resume method. And guess why? Because we didn't even seeing the you I off the application. And I told you that on a resume is called on Lee, If we see content that we have set in our layout file by using those methods, we can do some tasks that we want to happen in specific moment. So, for example, when the user leaves our activity, we can send some information to the our server to are to fire base, for example, we learn about fire base later in the course as well So if you want to send some kind of information I don't know, user just left this activity. You can do it in here or when the user lease activity at all. If you If it closed the app you we could do it in on destroy method. Now, I'm gonna tell you one more, Tink. Firstly, when the user opens the app very some class that firstly gets called and that class is application class. But we don't have it in here. So we would create it if we want to make some changes or if you if we want to do some tasks when the APP gets opened, no matter which activity was launched. So we will name this class app and we need to extend application and we will override on create method in here. Now let's based logging. Here I am. Let's name it upon. Creates cold. So now when we launched the app, this is the method that will be called first. Then it will call method on create in the activity that is launching activity. But we need to do one more thing and that is to declare this application as attributes off the name in Manifest like So So now Application knows that this is the class that will be lounged first. Now let's run the app and let's see what's going to happen now. You saw that on Create was called first, but in the AP class. So now we escaped on the resume because I forgot to remove finish from here. So that's it about android activity Life cycle, and I'm seeing you in the next video. 15. Playing video in Android app - Stream online video or play video from the device: Hello, everyone. In this video, we're gonna learn how to play a video in our android up. We'll also learn how to stream video, which is hostage summer online. So I've created new Android project. Everything is blank and ready to be changed. So let's go and open activity layout XML file and deleted these text view. So for presenting the video, we will use video view for the week. We'll use much parent and there's a height. I will set 500 DP. We'll also need toe add i d on the I d Will be video of you. We will now click on this a little stick here to infer constraints so that we don't bother ourselves with dragging from circle to the parent layout. Now let's open main activity and the declare video view like this. And now let's initialize it. So we have set the video view for the I D and we'll refer to it. So now we need something some video that we will be showing to the users in our app. So how to put the video inside our application? So firstly, you see this resource folder in here? We will put that video in here, so let's right click on it. And firstly, we need to create new directory and we will switch type to the roof. So basically Row is folder, where sound files video files on something similar is going to be stored. So that's why. Why it is called the rope. So let's click on OK and folder easing here. Now open your browser and let's start looking for the free radio example, and I suggest you to use one's from the picks a. B so all of those videos are free for downloading, and there are no copyright issues, so I will choose this one video. It looks interesting, and I will downloads this version, which takes 10.2 megabytes. And let's download it. No, we need toe. Find this file and, firstly, rename it to something like video underscore example. So we're renaming this file mostly because inside are rowed director. In here, we can't have numbers or or some weird characters. It will drove us an error when we run the app. So now let's go right click and copy these files and right click on the row and based it. Click on OK and That's it. So now let's see how to include these file in this video of you. So for that purpose, we need to use something called the U. R I bar, sir. So, firstly, we need generate you are I object which will be the path to the this file that we're going to play. So we will know tape You're right, the parse and we need to refer to these resource folder first and we're doing it by writing android dots. Resource is colon. It's less Lesh Now we need to refer toa are package name so we'll simply use package name metals and then we need to add one more slash and are those i d 0.0 r I mean mistake are not zero dot video example So now these your eye holds are filed or the path to it. So now we simply need toe say video view that set video you are I and we will use this one that is just created and now finally called video view dot start So let's run the up and c was goingto happen. So we have come up with these error which say's can play this video And that's because instead, off resource is we need to say resource. So let's try once again. And now you can see that video is playing. Now we'll see how toe add controller to this video so that we can play, pause or seek. Firstly, we need to declare media controller object. We will call it media controller. Here we will initialize it a new media controller and as a context we're using this, um instead of media store, we need to use media controller. Now we will set this media controller onto the video of you by using set media controller methods and putting this media controller. So you see how simple is that? Now we'll run the app again, Nancy. Now, if we click on this video of you, you can see that we have controller in here so we can pause. We can drag. Um, that's it. So now always the parts where I want to show you how to play video from the Earl directly. So from the let's say some server So let's go back to the browser and we will now find some free video. You are l for testing. Let's choose this one here on DWI will copy this link from there. So this is also free and we can use it toe play video. You are l instead of these sparse here we will simply based you are l that we have just copied and we need to do one more thing. And that is inside these manifest file. We need to include Internet permissions. So we didn't mention anything about permission so far. But basically, inside this manifest file, if mobile phone use is something external, it's a Internet or GPS location or something that can be used against the user against privacy. We need to declare it in here. There are dangerous permissions on permissions that are not dangerous. So Internet permission is kind off. Not dangerous permissions. So what does it mean? It means that we need toe Onley, declare it in manifest with using uses, permission tag on for the name. We will use Internet, and that's it. And if we used dangerous permission such as location so let's see, we have here access, fine location. Or, let's say, for example, read coal or right Cole log or something like that. That is a swell, dangerous permission. So for the dangerous permissions. We need to both declare it in here and ask user for the permission. So if you remember, when you use some kind off applications that need toe get your storage for example, Instagram needs toe need to access your gallery so that you can upload pictures. It firstly asks you for the permissions and once you allow it, it will never ask you again. So for the Internet, um, it is enough to just the Claritin here, And permissions that are declared in here can be found in our app info. So if we now close this up and weekly con a painful on, you can see we don't have any permissions in here. So it means that this up doesn't use any permissions. But if you now run this up, let's see what will happen. So firstly, we're seeing our video. This is the one. And now if we close our app and open app info, we still, um, we still don't see any permissions in here because Onley dangerous permissions will be presented in here. And this here will be presented if our happy zone Google play and user downloads it. So if you don't download some APS You have information about what that up use, so they would see Internet. But if you know boots, for example location. And if we now run the up, we will follow what will happen in these app info section. So now if he open and you see, we know we can open this up permission, It is not great. We see that there is location in manifest so we can manually enable it here or disabled. But if we want to use this location in our app, we would need toe ask user specifically through our app for that. So we'll talk more about permissions and how toe ask for it. But it is a little bit complex thing at this stage, so well, probably do it later in the course. So that's it for this one. We'll see you in the next video 16. Adding Launch (splash) screen: Hey, there. In this lecture we will learn about splash screen or the launcher screen of our app. So let's firstly take a look at some ordinary app that we have been building so far, how it looks when we launch it. So if I launch this app, for example, that animal app that we were building, notice when we open the app. Notice this white screen that shows up first, firstly, before we get our content. So we want to change that. We want to make our app looking cool. So this is how we do it. I have created Empty Project. I believe that you know how to create new project. We did it a lot in previous lectures. Now go and open manifest file. Here we see that activity that is being announced the first is main activity. And team of this main activity is actually this team in here, which is specified in application tag. I told you that everything that is specified inside application tag, it is applied to every activity in our app. If we want to make something specific to our activity, we need to do that in here, for example, or in here. So we need to change basically team of our activity. Team contains information about that launching screen. And when we set appropriate launching screen for the, for the team that we want to include in main activity, our task will be done. So let's firstly go in a resource folder, open values and open styles. Here we want to create new style that we will be using inside our main activity. Here we will declare new style and the name of it will be app team dot launcher. And what this means is that we want to change long-term preferences of our app team. So we will now close the tag. And in here we will put item that will say that we want firstly to make the window full screen. And we will hear find that attribute and we will set it to true. Now, we will firstly find the image that we want to show. In the, when we launched the app, I prepared image on the desktop. It is the logo that I've created. So we want to show this logo when we launch the app like the Instagram does, for example. So we will firstly store that image in Drawable folder. You can use whatever image you prefer. I will use this one. So what we now need to create is a layer list. So in Drawable, we will create new resource file. We will call it. Long-term or the better? Splash screen. Click on OK. And instead of selector, we want to use Layer least. So what is layer list? Basically, as the name says, we'll put layers to form lists of layers which will be representing our screen. So in here we will add items that will form layer of our splash screen. So first one will be drawable. And in here we'll put black color. After that. We want to put the image which will be shown. For that purpose, we will use bitmap. So bitmap will be inside item tags. For the source of the bitmap will be logo image. That's it for the splash screen. So we have basically a layer list. First item in that list is the background, and after it, we have the image. So next step is to go in styles and to apply this splash screen. So let's create a new item. We need to set attribute which is called window background. And in here we will use splash screen that we have just created. Now we need to open manifest file. And in here, we will specify the team which we have created in here. So now when we run the app, let's see how it will look like. So you see that there is no widescreen. We have splash screen that we have set up and then we have hello world when we open it. But we need to fix two things. First thing is, we don't want this image to be stretched like this, and we don't want to keep the background after main activities opened. So we want widescreen like on design. So first thing, we will fix this image. And in here, we need to put gravity as center. Then we need to go in MainActivity. And in here. Before we set content view, we will put set team. And we will now refer to this style file. And we will put app team that is the original one that, that is actually setup in here. So we only want to have these team before our activity is launched. So let's run the app and see how it looks like now. So now you can see that it is looking awesome. If we run the app once again. So because it was already opened, we only have, have widescreen. If we reopen it again. You see how cool it is looking. So now let's see what will happen if we change this color to white, for example. And let's now run the app. So now you see that it is not looking very well. And that's why I use the black color in here to make it looking perfect. So let's run the app once again to confirm that everything is okay. So that is how splash screen is built and this is the only correct way of creating splash screen. You will see many tutorials out there and 99% of them will show you wrong way of creating splash screen. So what they teach is that inside onCreate method, they are setting some kind of timers which will show the image that you want for some period of time. And after that, they will remove it and you will see this white screen. But that is not correct way splash screen is not used just because just to show you something, purpose of the splash screen is to be shown until our app gets loaded. And we must and keep our user waiting just because we want to show something for a certain period of time that is bad user experience. We're just replacing that poor looking white screen with something that looks much more cooler and makes feel that our app is professional. So this way is only one that is correct when it comes to the launching or splash screens for your app. So I hope that you enjoyed this lecture and I see you in the next one. 17. Android permissions and using Camera from our app: Hello there. In this lecture we will see how can we take a picture from our app and put it in some image view? So we will see how to basically open camera from our app. So let's firstly make some changes in user interface. We will delete this TextView. So we will put ImageView. Let's put the 350 DP for the width and 354 the height. Let's put some ID in here. Let's call it image. We'll put it somewhere in here and we will constraint it. So let's put some background as a place holder for something like this. Now let's open main activity and the declare and initialize these image view. Like this. And all. Let's add button in here. Text will be take a picture. Id will be btn camera. And we will move it here at the bottom. And let's constraint it. So now let's initialize and setOnClickListener. So called the three right in here. It will be executed when we click this button and we want to open the camera. So let's see how it's done. First of all, we must ask user for the permission to use camera of the device. And if the user didn't allow camera, there is no chance that we can take a picture with it. So first think when it comes to the permissions, is that we need to declare that permission in manifest. And in here we will use a uses permission tag, and we will choose Camera as the name. Then when the user click, we firstly must ensure that camera is allowed, that using camera is allowed from the user. So let's see how we check that. So we will put if statement, which will say if check self permission. We will now refer to the manifest dot permission. Dot camera is not equal to the package manager dot permission granted. So here it means that User didn't allow. Or more specifically, it means that using camera is not allowed. So it doesn't mean that user denied it. It means basically that using Camera is still not allowed. So we'll put him here. Using camera, not allowed. And if this is the case, we need to request permission for the camera. And we're doing it by calling request permissions. And we here need to put string array. So we will here create one string permissions. And we will put in here manifest.yml permission that camera. And if you wonder why we use string array, why we don't just use simple string. That's because we can ask for multiple permissions at once. So we could hear, add, for example, manifest permission, cell phone, or read calendar, or we could add many more requests, but we will use only camera. So in here now we will put this string array. After that, we will put comma and the request code. So we will hear declare that request code. So let's type in P, S, f, i, and press the Enter key and it will generate public static final integer number, which will be called camera permission code. And let's set it to one. So now in here we will refer to it. You will see later why we use these permission code. And in here, if the user allowed camera or camera is allowed to be used in this app. We will simply open the camera and take a picture. And let's see how we do that. We will create new intent, which is called camera intent. And it is equal to the new Intent. Media store dot action, image capture. And then we will start activity for result because we want to get the picture that is taken. And we will here put this camera intent. And in here, we need to use another code, which is in this case code for the picture that is taken or the action that happened when we opened the camera. So you will see later why we use that as well. So let's create one more. And let's, let's say here camera image Goethe. And let's put it to. Now referred to it in here, like this. So now you can see errors in here. And what are those errors? It says that these coal requires API level 23 and current minimum is 16. So this is 16 when we created project. And why we why we have this warning? Well, that's because before API level 23, those requests didn't even exist because those devices had everything enabled and allowed for using without users permissions. So basically, requesting permissions didn't exist in that time. It is introduced in API level 23. So here we will check the version of the device that the user is using is higher than API level 23 or not. So we will hear now, press the enter and we will put if statement, which will say if built dot version dot SDK int is higher or equal to the build dot version. Dot codes, underscore codes dot m. And this m stands for the marshmallow, and you can see it is 23 in here. Value of that. Permissions are introduced in Android Marshmallow. And if is this the case, we will here open the curly brace and we will close it after this one, like this. And if IIS version below Marshmallow, we can know for sure that we can open the camera without questioning the user. So we have code duplication in here. So it is a great opportunity for creating method, which will be called take picture. And we will cut this code and put it in here. And we will just here called Take a picture as well as here. So now let's run the app and see how it behaves. And later we will see how to store the picture in the image view. And if we now click on the button, take a picture. You see that we have dialogue which is requesting permission from us. If we click allow, it means that permission is allowed now. And if we now take a picture, it will open the camera. And we can take the picture. And once we click on this, we will get a picture in our app. But now we need to set that once the user allow using camera. Camera will be opened instantly, so we don't need to click on the button once again to open it. So let's see how it is done. So when the user allows or denies some requests for the permissions of something, there is a method which is called On the request permission or result, which will be called. And in here, we can check if the user allowed permission or not. And we will put if request code is equal to the to the camera permission code. So firstly, we want to check if this request result is in relation with the cameras. So maybe we asked for many other permissions. So in here we firstly must check if it is above the camera. So that's because when we requested permission, we hear put camera permission code. And here we are waiting for that permission code to check. Now is the permission is granted or not. So in here we would put if Grant results, and this is integer array, and we want to get the first item in that array to check if the, this is Package Manager dot permission granted. This means that user now clicked on allow. And permission is granted at this point. So we can open the camera from here as well. And now, when the user allow using camera, camera will be opened right away. And if the user didn't grant permission, we will put those, which will say app needs permission for using camera. So let's now firstly, deny permission by going in app info. Click on permissions on camera and deny. And you can see that our app knows that we did. We want camera permissions and that's because in Manifest file we have put that thing. So now let's rerun the application. Now click on the button. And let's firstly, clique can deny. So we have these toast message from here that says that we need permission. And if we now click on Allow, camera is opening immediately, so we don't need to click once again. So now is the time to see how do we get this picture which is taken and how to put it in ImageView. So for that, when we open the camera from our app, you see that we are opening it with start activity for result. Which means that after this activity gets finished, we will get some result in return. And we will get to that result in method called on activity result. So in here, we will check if the request code is camera image code. Now you see why we use that code. We send it here and we want to check is the result coming from the camera image. And we need to check here if the result code is OK. And result code okay, means that we have basically clicked on this thing in here. Or you will see later in the course that we can manually put a result which will be returned in here. So in here, we have a picture. And now let's put it inside the image view, which is declared, which is initialized in here. So you see these data that is also coming to us. These data holds image and our image is a bitmap. Take an image and it is equal to the data.dat get extras, dot get data. So by default, we are using key data to retrieve the value of the data. And here you see that this gap is returning an object and we are required to have bitmap in here. So we will simply click here. And we will cast this row object to the type that we expect. And if, and if this object is actually some other kind of value, and we cast it to bitmap. It will cause an error. But we are sure that this is bitmap because we are getting result of the image. We can cast it like this. And then we will just say image dot, set image bitmap and take an image. So now let's rerun the app and see what we have. Let's take a picture. And let's click on this camera. And click on this. And you can see that we have a picture in here. And it is working perfectly. So if you wonder, why do we have this kind of image in here? That's because this is emulator. It doesn't actually have a camera. It is just some kind of emulated image that can help us build our apps. It says that if I hold Option key on my Mac and the move the mouse, I can simulate a moving phone around this room. And if you are using Windows, it is probably old key on your keyboard. So I hope that you enjoyed this lecture and I am seeing you in the next one. 18. Make QR code scanner app - Part 1: Hello everyone. In this video you will see a preview of the app that we are going to build in the next lecture. Functionality of that app will be scanning barcodes and QR codes. So we will be able to scan the code and result from that scanning process will be displayed in these button where we can see now starts scanning. At the moment, I'm sharing screen of my physical device because we will need to use camera on a real phone so that we can scan something really. So now I will start scanning and I will scan some bar code from the product that I'm holding in my hand. So when we click on start scanning, it will first ask for the permission to use camera. And when we allow it, we will now have these activity, which will scan the barcode and we will have the result of that in this button in here. Now let's see how it works when we scan the QR code. Now, I will scan QR code that I have prepared in here. So when we get the scan result, it will be displayed in the button like before, but now we have some texts, or in this case it is website. So how to build all of that? We will see in the next video. 19. Make QR code scanner app - Part 2: Now is the time to start creating barcode and QR scanner app. So let's firstly create new Android Studio project, choose empty activity and call the app QR and barcode scanner. And for the minimum SDK, we will set 19. And click on Finish. Now everything is ready and set. So we will start creating this app. Firstly, let's here add the button, which will be Click When we want to start scanning process. So let's make it to wrap content. Text of the button will be start scanning. Id will be btn scan. And we want to make our text as it is, so we don't want it to be capitalized like on this preview in here. So for that purpose, we will change attributed text all caps to defaults, which is true. By default. Let's put it somewhere in the middle and constraint it like so. Go back to the main activity and let's declare the button and initialize it in here. Now we will set on click listener for this button. New onClickListener. Here we will start scanning when the button is clicked. So how we do that? Now? When we click on this button, we want to be transferred to the activity where scattering process is being done. So for that purpose, we will create a new activity, which will be empty one with the name scanning activity. And click on finish. Okay, so now let's open this activity and split the code. For scanning barcodes and QR codes. We need to use some third party library inside our project just when we wanted to use circular image and we needed to include another dependency. So open your web browser. And let's start typing for the QR scanner library, Android. And we will choose this one here. So you could use any other library. But since I built the app that I showed you using this one, we will use this one. So to use code from this library, we need to include these dependency. So we will copy this line of code in here, and we will paste it in Gradle scripts, in build-up Gradle file in here. And we will click on Synchronize project. Now this library is included in our project, so we will now see an example of how it is used. So we can see that we need to define these codes scanner view in our activity. So we'll copy this and we will paste it in our second activity in here. So now we have the desired scanning view. And let's now see other instructions. So here is instruction in coupling and we are interested in Java now. So firstly, we need to declare Code Scanner object in here. And we need to initialize code scanner view. And this is the view that we are looking for. So we need to initialize it in here like this. And then we need to initialize this object from here like this new code scanner. And we need to put context in here, which will be scanning activity DO this AND scanner view. So we need a view that will be scanning in which we will see preview of the camera. And to start scanning, we will need to code M code scanner dot start preview. But to start Preview or actually start scanning process. And we need camera permissions. And we will ask for the permissions in the main activity when we click on the button. But firstly, we will declare that permission in manifest file, like so. And then here we will create new method which will be cooled. Start scanning activity. And in here, we need to firstly check if the version of the Android, that device is using higher or equal to the version marshmallow or the API level 23. Now in here we will check if the check self permission and camera permission is not granted. We here needs to ask for the permission. And if the permission is already granted, we will start scanning. We will also start scanning immediately if the version is lower than Marshmallow because we don't need to ask for the permission at all. So here we will ask for the permission and we will call request permissions. We will just create string array on the fly so we don't need actually variable and all the instantiating process. So we will just create this one like this. Because we don't need to use that variable later anywhere. And we need to create public static final integer, which will be the constant for the Camera request permission. It will be number one. So these final means that this is constant and it can be changed later. And by the convention when we're talking about constants, all, all letters must be capitalised in our variable name. So you can see that this camera is also capitalised and this is also final variable. So here we will refer to it. And now we need to start activity. But for results, so we need to get a result of the scanning returned in this activity so that we can update btn text. So we will start activity. For result. We knew intent from MainActivity.java, this 2D scanning activity dot class. And we will hear now add request code for the activity result. And we need another variable for that. We will now call it scanning request code and value will be two. We will put it in here. And we will also do that in here because we have permission is granted. And now we will call this method when we click on the button. And now we must override on request permission result to see if the user allowed using camera or not. Here we will check if the request code is equal to the camera permission request code. Here we will check if the permission, if the grant results at index 0 is equal to the package manager dot permission granted. And if it is the case, we will just start scanning activity here as well. So let's start the app to see how it looks like at the moment. If we click on start scanning and allow using camera, we will open these scanning activity with camera opened, since this is the emulator, it will look like this. But if you run it on physical device, it will be a real camera image. So now how to know that scanning is finished. We will do that in scanning activity, but to see how it's done, we will go back to the code example. And we can find that here is the code callback, which will be triggered when scanning is successful. So we'll here add that callback on the M code scanner, like this. And we will add new decode callback in here. So this result will hold value which is scanned. And here we need to pass that value somehow to the previous activity. And let's see how to do that. We will firstly create new intent in here. And in this intent, we will put scanning result. And that result, or the value of scanning will be result a dot getText. We will now set the result to the result or K, and we will put this intent. The last thing is to close these activity with calling finish for now to get these results in the main activity. You know that we have started this activity. We'd start activity for result. To get that result, we need to override on activity result method. And in here we will check if the request code is equal to the to the scanning request code. Here we will check if the result called Is equal to the result of K. So now you see why we use result. Ok? If we here put the result canceled or something else, here, we would have different flow. So when the result is okay, we will get this data and we will set it to the text of the button. So let's refer to the button and set text. Data.dat, string extra. And the key that we have put in here, which is scanning result. So now I will run this app on my physical device to test if everything is okay since camera on emulator can unfortunately scan real barcode. So here is my device. I will now run the app on it. App is now running and I will try to see if the scanning you working. So it works perfectly. I hope that you enjoyed this lecture and I'm seeing you in the next one. 20. How to make your app fullscreen: Hey everyone, this lecture is going to be your short one. I'm going to show you how can we create app, which is full screen. So, so far, if you run this app, you will see that this is not a full screen app. So we have here battery and other informations, as well as this action bar in here. So let's see how to make full-screen app. So we will choose empty activity. Then we will click on finish. To make the app full screen, we will need to open resources, values, then styles. And in here, we will firstly add new item, which will be called window full screen, and we will set its value to true. Now let's go run the app and let's see how it will look like. Now you can see that there is no status bar which holds information about battery, clock and similar, but we still have this ActionBar in here. So how do we get rid of this? We will add one more item, which is called window, no title. And we will put this to true. Now let's run the app and see the result. So you can see now that our app is full screen. And if you wonder why do we have those three in here? So those three are device specific. They are navigation buttons and we shouldn't mess with those. So if you go to the manifest file, we see that we are applying team to our app and every activity that we make will be full screen, like you can see in here. And if you want that to make just two specific activity, you would need to create new team, which will have those two. And you would then apply it to specific activity. So let's see how it is done in practice. So we will now create new Activity, Empty Activity. And we will just set onClickListener on this TextView. So firstly, give these text to you an ID. Let's call it dx, dy. And in main activity, we will declare it and initialize it. And we will set onClickListener. When we click it. We will just start a new activity. And we will go from MainActivity, the disk to the main activity to dot class. And now if you run the app and we click on these Hello World text, we will get to the main activity tool, which will also be full screen activity. So let's go and click. So this the second activity which is also full screen. But let's say that we want only the second activity to be fullscreen, but not the first one. So we will go back to the style styles file. We will move those to the new style, which will be apt team, my team for example. And we will here put those. So we will also say that we want to extend this one from here. So we want to have basically same team as the our application have, but we want to have full screen activity. So we could also copy those three in here. And now in Manifest file, we will just here in the main activity to say team, this one. And now let's run the app and see the results. Main activity is not full screen. So let's click on Hello World. And second activity is full screen. That's it for this lecture. I'm seeing you in the next one.