Android Firebase integration 2020 | Maid Rondić | Skillshare

Playback Speed

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

Android Firebase integration 2020

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

8 Lessons (54m)
    • 1. Introduction to the course

    • 2. Firebase Integration

    • 3. Signing Up User

    • 4. Logging In User

    • 5. Getting an Image from gallery

    • 6. Bug fixing and Logging User out

    • 7. Uploading selected photo to a Firebase

    • 8. Saving User informations to Firebase Database

  • --
  • 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.





About This Class

Hello everyone,

Firebase is one of the most famous realtime databases and backend services created by Google. The service provides application developers an API that allows application data to be synchronized across clients and stored on Firebase's cloud.

In this course we will learn how to integrate firebase into our android studio project from scratch!

We will create sign up and login pages in order to register and log in our user. We will see how to upload photos and other informations to the firebase server.

Meet Your Teacher

Teacher Profile Image

Maid Rondić

Professional Android developer


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!
  • Yes
  • Somewhat
  • Not really
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.


1. Introduction to the course: Hello and welcome to this course. In this course, we're gonna learn how to connect our enjoyed application toe a firebase server. As you may already know, Firebase is a ghouls online database or online Google Service platform, so it is used for keeping informations and data online. So let's take, for example, a Facebook application. When you register, new user informations about that user are going to be stored on some server on cloud, and in this course we will see how to do something like that. We eat fire base. We will learn how to sign up new users how to log in existing user. We will also see how to log out the user, and at the end we will show how toe applaud an image to the server. So let's get started. 2. Firebase Integration: Hi there. This lecture we're going toe integrate firebase in our project. So let's start by creating new entrants to the project for activity. Let's use empty activity And for the name of the application, let's say fire bees. We will leave this as it is become fish. Now let's wait a bit. Okay, So now when the build is finished in order to integrate firebase with our project, we simply click on tools and then or four ways. As you can see now, this assistant window is open. We first need toe set up authentication toe our project. So identification is used for signing up on signing in our users. So let's click on email and password education and connect So far base. Now you got to choose your Google account. I would choose this one and you need to allow access so quick on fire base. And now you can go back to hundreds to you. So, as you can see, I have no signed in in 100 studio with my Google account. Name of this application is far based up. But as you can see, I already had this up in my firebase projects, so I got to use far base up to now. Well, simply no click on connect far bays. So now it is finished and we can see here collected. Now we need to add dependencies in our project in order to use far base coat. So, pelican at fire base authentication to your app. As you can see, it will apply some plug ins and it will add implements in our great I'll file. So it's just click accept changes and it is done. You can go inside your firebase console and you can see now that Firebase Apatow is created here or whatever you called your application. I can click since, like here. And that's it. This is our dashboard. This is where we see our users. Any data that is uploaded to the server and similar in the next video We'll see how to sign up. You, user. See you in the next video 3. Signing Up User: Welcome to this lecturer. In this lecture, we're going to create our sign up activity and register our first user toe. Ah, fire base. So let's see how it is done. We would close his assistant for now, and we can rename this activity toe sign up activity. So let's click on Reflector. Let's click on the rename. We'll see. Sign up and reflector. Now let's modify our activity main dot xml So first, let's click on this. I can hear and click on show layout decorations in order to see EPA barley out. Listen to me, this text to you. Let's plain text here at this country. Just one more and now let's add a button. So let's hate this field will be for entering email. Thanks. And his hint We will say e mail for the I d. We will say had it text you may we will say Don't ask again that leak years. So this will update all I ds, which are used by the said text to you within your name, and this one will be for the password will say it bus word. We will delete text and for a hint, will say password We cannot change input type for this field to be a password. So when the users typing is but it's password, we will see only dots and not the text so we won't find next bus word. It's OK now Let's change. I d for this button. L That's a beauty in. Sign up for the text. Let's see. Sign up and that it we'll make it simple. We will not make any prettify Inga rounding buttons and shaping. We can do that later. But for now, let's make justice up work. Let's work on its functionality. Let's go back to sign up. And here, let's declare our you I components. So let's see Unity e mail on e d. Best Werth. Now let's be clear. Button Bt in, Sign up. Now let's go ahead and initialize. Are you? I components. Let's say he t mail et email. The knowledge initialized R E t Best word best. Also, let's centralize are button and that's it. Now let's add some fire base coat, so let's click in these assistant again. As you can see on our on create method, we first must initialize fire base authentication instance. So let's first declare it here. As you can see, it will be important automatically and inside our own create metal. Just simply copy this one and that's it. Now we can add our code for signing up a new user. What's said on Fleek Listener for this button, it's a new Uncle Ike listener on. As you can see here, we simply referred to these I m out Indication Variable en recall. Create user read email and password method. So let's simply say dot Create user it email password and we will say ID et email dot get text dot to shrink and DDT password. Don't get text to ST. We'll also add on completely sinner in order to see whether user has successfully signed up or not. We will also if statement and we will refer to this desk and we'll see if this task was successful. Let's bring those message which will see user has registered. Don't forget to add this semicolon. And here let's at l statement, which will say ask dot get exception dot get localized message so this will print out or totally message about exception. It has occurred while trying to register user in our phones, language So, for example, your phone is set in Chinese. This message will be simply printed out in Chinese, and now we need to do one more thing in orderto get our user successfully created. We must go back inside are fire based console and let's clicking on these authentication and we need to set up signing methods. So click here and we need to enable email. Password it Education. Now, when it is done, go back 200 studio simply around the application. No, let's wait a bit until everything is ready. OK? No, let's type female. Let's say, for example, Max at May don't come. And for the best for let's say life Quicken, sign up. As you can see, user has registered and we can confirm that by going in tow council and clicking on users. As you can see, our user has been successfully created. In the next video, we will see how to log in our user. So see you in the next video 4. Logging In User: in this lecture, we're going to create logging activity and enable our users to log in. But before we proceed doing this, we must fix a buck. As you can see when we try to log in with empty password, for example, or empty email field, our app is going to crush. And there's because password or email field must be empty, so we will fix it simply buying, adding, if statement in our own click method before creating user, we'll see if DVD email don't get text to string, but he's empty or unity Password. Don't get text up to stream is empty. Well, simply printed. Those message, which will warn user that empty feels are not allowed. And we'll simply return by adding this return. Here, you're preventing our code toe be executed furter away, so exception can't happen. So let's run dear and we feel click sign up. You can see that those messages showed to the user and app is not crashed. So now let's go create lugging a duty. Let's click file new activity on empty. Let's name in this, you know, let's click on activity underlying log in XML on scene please. Two plain texts for email and password. Let's change this idea Toe entity E mail. Well, okay, so we can differentiate between our e mail from sign up page and, well, that's really text or the heat. Let's see you may for past for let's say, DDT password look and also let's change include type to text. Best word for the bustle. Let's say beauty in looking. Look. No question is how to access this logging page in a wrap. So first we will add Hey, text to you inside our sign up activity here, for example, and we'll say already, Shevin count. Lug it. We'll change, read Toby, fraud content and, for the ideal, say txt lucky. So let's declared his text you here, Let's initialized here and was Make on click listener. We will simply creating new intent object from sign up activity that this to well, logging activity don't glass and simply start activity intent. So let's first test it out to see if it works. So now when installing is finished, if you click on these text to you here, you can see that Logan Page shows up. So now let's add a code for looking in our user, so go back to the logging activity. But first we must declare our fuels and button. Let's initialize them. No, let's go and implement code required for looking in our use So we can also usar assistant to make it easier for us. We don't need to. We don't need to remember discord by heart. We can simply take a look. As you can see, we need these m authentication for logging in user also. So we will first declared again here on simply initialized. Now let's sit on quickly. Sooner now, we will also check whether some feel these empty or not. So let's add if statement even this is the case that simply show message to the user on the return. Now let's implement Coat needed for logging really was signing with email and password, as an email will say et while Ginnie Mae Low to get text to strength and for the past middle c t working password Don't get text no to strike and we will also add I'm completely sooner. So first put here semicolon And if the task was successful, we will say user log on its not we will see. I asked to get exception, get look like message. So let's try to sort so click on Logan. So let's enter the email of the user that already exists. Also make sure that bus word is the same. Find Logan as you can see, User. He's lucky. So this is how we implement looking feature single Next lecture. We will see how toe look out our user and how to upload a picture to the fire base. For example, See you in the next video. 5. Getting an Image from gallery: so welcome to this lecture in this lecture, we're going to make home page and we will see how to select an image from a gallery and put it inside. Image you. So let's get started was first, create a new activity. We will choose empty activity and we will select and we will rename it to Home Peach. Let's click on finish, you know, simply going design turbo off activity and we will put an image view. Here we were. Just chew some color as a placeholder. Let's say this one. We will, of course, trained, and we will expand it a bit now for the idea of this image viewable. That's that image I applaud. Now let's go inside home page and let's declare it, Give me jump plot. Let's initialize it. No, let's set a one click listener with right you space and then hold shift key on your keyboard and press on click and it will out a complete it for you Simply enter key Now. Now we will create a intent you intent, and we will say intense, that action pick for the intense type. We'll set it Toby a image and now just start activity for results. Now type in intent, objectivity created and request coat. Now, when we choose the image in orderto get it and do something with that image, for example, in our case, we want to place it instead of these green background here we need to override on activity for results method. So here. So in this method here, we're going to manipulate with the image which is selected in this cold here. So first we'll make an if statement which will check if the request code is the same as zero. Also, we need to check if the result code is result. Underscore. Okay. And we also need to check if the data is not equal to know if all of that is true, Let's do following. Now we're going to create our new private variable, which is which will be off type your I. So this will hold our selected photo, and here we will simply say photo is equal. Data don't get data. So now we need to convert this photo to a beaten up in order to place it instead off that green background on the image view. Now we need a variable of type of beaten up here we will see beaten up equal media store dot images dot media dot get beat up. Now we will see get content trees over and for do your I will simply say for now. As you can see, there is some error and it is about Java filed found exception that might a cure while selecting an image and i o exception. So we'll simply surround this inside. Try cash block so the compiler will not complain about it. And we will make those message in order to let the user know but something in 12. Next, we will place our image as a background off the image you. So just a image upload upset. You need to beat map business. Now we need to make sure that when the user log scene, they get transferred to a home page. So we'll do that inside. If statement off this completely center just after the user logging message. So we will say intent. Well, your activity dot this home page of class and started it. So now let's run the app and try it out. Solis Logan, right? Credentials. I could and click on looking now when we click on this image view, we can see the galleries being opened when we select the image it is shown here. 6. Bug fixing and Logging User out: in this lecture, we're going to fix small Bug that we have an implement log out functionality. So let's first see that bag what it is about. So let's run the app and let's Logan the user. Now you can see differently going back button. Here it is showing us log in page, and that's not what we want. We need to disable this somehow so we can solve it in two different ways. One raise toe override our back button, which is not that a good idea. And second way simply clear our activity stack. So let's he holds done. We'll go inside, log into Java file and just above the start activity, we will do following I will say intent. Don't set flags. Uh, well, say clear test. Put the symbol here and say again, You didn't got new task. It will clear all activity stacks before so we can go back. So let's run the app and let's see what it means in practice. So let's go again now. And if you click on back button, I am simply closes and that's it. No, let's go implement logo with functionality. First go and put button for looking out. Place it here. As you can see, design of the APP is not that good. It's actually very bad, but we don't care about it. Really wanted Toby functional and working. It's a beauty in look out logo. We need to add one more mystery and that's it. No, let's go inside home Page declared it button and single. That's initially let's changes to a small case letter. No, we will simply said Oakley. Kleasen er right down you space whole chieftain see on and percent of and now just referred toe authentication object that we have. But we must first initialize it here. So that's a pilot. Our baser authentication f A. And let's say it's equal. Don't guest instance. No, simply refer to these FAA all virginity created and say Sino and that's it. Our session in beckoned will be closed and user is actually loved out and now will create an intent object to transfer us toe a sign up page. I don't simply start activity. We don't need for results. You start simple activity, and we'll also at this cold here for clearing stacks because once user is logged out, we don't want him to get back without session. So actually, what his session session is an object which is created once the user is logged in. It keeps some information about users such as email or user name or anything on session keeps track about our logging state. Actually, it keeps track whether our user is logged in or not. So we tried out was Logan. And as you can see, our up has crashed. And that's because we refer to a wrong button here. We need to say beauty in loge out, actually. So that's right again. Click a longing typing credentials. Just click on logo and that's it if you go back to close up because we cleared old previous activities and that's it for this tutorial. See you soon. 7. Uploading selected photo to a Firebase: Hello there. In this lecture, we're going toe finally upload our picture for fire bees. So first of all, we must enable firebase storage. So we'll click on tools firebase and find storage. Swivel, Click on upward and downward file with cloud storage and we will add cloud story dependencies to our approaching. Now we will go inside our fire based council. We will open our project. We will now go on storage here and we will keep on guest. Charity will go next. And don't so we will select this Go on finish. So as you can see, there is nothing here and now we're going to upload the picture through the injuries to the local. Now we need a reference toe. Our database Sweet. Well, first, as suggested, declared here and then on create method. We will initialize like so and now we'll make a function or a method for our applauding dusk. But first we can create a button in our home page activity for uploading purposes. So we'll put it here. I would say BTM upload for the i d. The fourth decks. Let's say uploads. Now let's go back to the Java code. The Clarity's Botham and let's initialize it here. So now let's creating method for applauding dusk. So, first of all, we're gonna need a unique name for our picture. So how to generate a random string? So we will use you. You I d glass for the specific desk. So let's take string. Random name is equal. You I d random you i d What street Now we need something like a folder in our database storage the place where all photos will be. So let's click inside, get reference braces method and simply see images now because every time we applaud new image, we want to random generated name We must move this statement from one create method our upload image method so we can hear simply add our random generated It's drink And now we just say I'm storage dot good file and we put file called photo, which is, if you don't remember right here. Now let's just said on click Listener for our button New Ochlik, listener of the just call upload image and that's it. Let's go and try the app. Okay. No, First, Logan, Now select the image and go upload so we can check if the image is uploaded. They're not in fire base. So referenced page. And as you can see for the images, he is generated for us and there is a picture inside. So let's see. That's it. Now it is better to make an incomplete listener so we can see your picture is successfully applauded or not. So we'll just add this one completely sooner. And we will put if statement which will check whether applauding process was successful or not. Okay, so let's write again. Okay, lets go. Logging again about selected the focal employees. Picture a bloody So let's check. So as you can see pictures here, so that's it. I hope that you have enjoyed building this simple up. It's nothing special, but you can use those skills in some other projects. I hope you enjoyed and see you soon 8. Saving User informations to Firebase Database: No, we're going to see how to save user into a database. So first going Fire based council and open your project. Then click on database and now we must enable it. Click on, Create database on unless shows testimony so frequent. Next and click one Done. So I was being created for us, he said. Don't go here and choose a real time database and that's it. Now let's go Big toe Android studio and let's create class named User. Because when we store informations about our user, you must first create object off type user Cinderella's Go and create New Class. Yes, sir. And this class is going to hear property called You Made User Me and I D. So every user is going to have unique idea. And now let's make constructor reach except those parameters and let's assign them and always going to make some changes are a sign of activity. Let's first and a new field for the user name. Let's give a hint and I d will the unity news earning, always going Java class. What's at the said Thanks. And here let's finish. So now when sign up is successful, we're going toe also say the user to our database. So first, let's make a method which will do that task for us. First, we're going to create that object off type user. So let's first except email s parameter no user name and no I d to get I d off our current user. We need to We need to call this metal our bases get the instance. Don't get current user, get your i d. And he forgot to put new here. So that's it. Now to save the user, we must first include firebase database. So let's go. Tools down Fire base. Let's choose really time database. Let's added. Okay, now build has finished. Well, let's continue working without a coat was forget the reference to our database. So let's see. Database reference D R. Is equal to firebase database. Get instance, get referenced and let's put user here as the name of the Let's Say class, you will see later in Firebase council how to look like and now we will simply called D R set value and we say you use So now let's call this method All right here. E. The signing up task was successful so let's say save user data, please. I was also said here, a listener, so we can know if the task was successful or not. So let's bring it out. These error message. Let's try out. Let's run the application. Okay, so no, it's typing told me. And e mail will be Tom at what may look calm and put some password here. Click on Sina and now our obligation crashed. So if we open locket and search for their it say that no properties to serialize found in class. So that means that firebase doesn't know which attributes should be saved in the database. And that's because if you click on user class, we will see that those are not public so it can see them. So let's change this to public on. Let's see if that's gonna work. Now let's rerun application again. Okay, so now we must use different credentials. So let's say Alex Alex at gmail dot com. Password No sign up. So now it say that permission denied, and that means that we forgot to enable reading and writing in our database. So let's open the rules here and for the read Let's say true. Let's also right. True, and we can publish. So now we'd saved. And now if we try to sign up, you use it will say Alex one. It's one since he was going to happen. As you can see, new users showed up here, and if you click on plus, we see unique I d off the user email and user name. So let's see, What is this idea about? We go in authentication. We can see that DC's the I d off the off that users. So let's say one more user to see was going to happen. So now let's say Maximus, always go sign up. Now is you can see this user is over written with the new one, and that is what we don't want. So how to overcome this problem? Let's go big toe injury studio and let's see, when you user signs up, we will change the pet off thes reference. So if we go something like this, plus user name 80 user name, don't get text Dr ST Let's he was going to happen now, so let's run app and let's delete this one entirely, so let's see what's going to happen now. So Let's see this user. No conceded to him. One more branch. And if we know register new user, we'll just hear another one as you can see you. And that's what we want. So this is how you save users into the database. And I hope you enjoyed this week. So see you in the next one.