Firebase Android Tutorial - Part 1 - User Registration

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to firebase tutorial series this is the very first part of the series and today we will do some cool stuffs the start with knowing what is firebase if you don't already know firebase is a cloud service that gives us the tools and infrastructure we need to build better apps quickly it provides real-time database authentication Cloud messaging storage hosting remote config test lab craft reporting and analytics and many more you can see in the image firebase is available for various platforms but in this video we'll be developing an Android application and in this video we will learn about firebase authentication only so let's start by creating a new Android studio project so create a new project give it a name I am giving firebase or demo and click Next again next select an empty activity and finish and now wait for the project to get loaded while our project is loading let's create our app in firebase console so go to firebase google.com this is the website and click on get started for free here we will create a new firebase project so click on this button create new project and give your app name you can put any name I am giving my firebase or tap now go to your app and in this screen click on Android application here you need to put the package name of your app so go to project again and inside manifest dot XML you can get the package name and copy it from here this is my package name your package game can be differ so copy it and paste it here and click on add app now you will get a file name Google - services dot JSON we need to put this file inside our project this file contains the details of the firebase app so let's copy this file click here on project expand the project folder and inside app paste the file which is copied now we need to add Google Play services in our project so copy this line and paste it to the project level bill dot Gradle file this is our project level build or title file and the line we complete will paste a team oops now again copy this line and we need to paste this line inside our App level pill dot cradle file and at the bottom of the app level build or greater file we'll paste this line oops here now sing the posit and here we'll click on finish' as we will be working with authentication so in the left side you can see the auth so click on earth here we need to set a sign-in method so click on setup sign-in method I will be using email password it is now disabled so enable it and save now as we are using firebase odds so we need to add firebase earth in our present so go to get started guide and scroll down here and find the auth copy this line and paste it again to your app level built or created file and site dependencies block I am changing I'm changing it to Version nine point two point Co because nine point two point one is not working again saying the project and after sinking firebases added so easy right only this much stuff saved us from coding the server-side code PHP MySQL and so on the dolfe eight anything there this is enough to build the apps by using five days so as few be working with Internet so we need internet permission added in our androidmanifest.xml file so go to the manifest file and add internet permission so come to activity underscore main dot XML here we will create a two at a text to enter email and password and one button so let's create it I'm putting all these inside a linear layout so first we created and the linear layout and the or e attention would be what sorry we don't need an ID for this linear layout will define orientation only and center vertical and center horizontal will be set to true so that the layout will be on center of the screen now let's create edit text this one is for email give it an ID edit text email and hand would be enter your email or something like that you can change it to whatever you want no I'm copying it so that I can cut the ticket field for a password and just change the ID enter your password and we'll change the ID of the edit text here I'm defining also input type this is for email and this is for password so that the feeds would be hidden now create a button after filling the fields user will tap this button to get registered on our app in button we are showing mr. user text and given ID to a button it is put in register and will create one more text view it would be behave as a link so if you are already the register you can click on this link first set the margin so that it will look more good as you can see on the preview now let's create an ex to you in this text view we will display like already registered login now or something like this let's write something here already registered sign n here so if user is already registered user can tap here to go to the login screen directly it's not looking good so make it aligned centered this is cool our screen is ready actually this is our UI for the first screen and it is ready now let's code the functionality so first we will declare the views so come inside the main activity class and define the views here so we will declare a button object put on the disturb and again a text object first one is for email and other one is for password now for the link text text view object is also needed now we will initialize our views so you know how to do this while you buy ID or not I did our tidy we give a non XML file this is quite easy same for emails oh sorry edit text and text use oops I have written signup that should be shinin as name doesn't matter but it should make some sense so I am writing sign this is now to add the click functionality we need the view one click listener so we'll implement the interface view dot on click listener and now we will implement the method on clip the method is implemented easily now we will attach the listener to our text view and button register so we can do this by setting an on click listener and the listener is on the same class so we are passing this same for the textview and inside the onclick method we can track with this view object which view is clicked so we'll write if the you sorry if you equal to equal to button register then will register the user so I'm calling a function register teacher which is not created yet but we will create and if you equal to equal to text you sign then we will open the login activity so we'll open sign-in or login activity here now let's make the register user nothing so here create a method private void register user first we'll get the email and passwords from the added text to edit text email don't get text or to string or trim you know all these already password same for the password edit text password forget text not to string button now we will check if whether the strengths we got are empty or not we can easily do this by using text utils class so if text util start is empty and we'll pass our email that means email is empty the same for the password so user cannot go for that without entering an email or password here will display a toast that you should enter your email and you cannot go further without entering the email and then we'll put return and return we'll stop the function from executing further same here for the password display a message with a toast and we'll put return to stop the function execution now if our code comes here that means the email and password is entered and we will register it our user and because this is an internet operation and it would take time so we will use a progress dialog to show so we'll show progress dialog while the user is registering on the server so initialize the protest bar object and we'll us and we will certain message for the progress bar oops we should use progress dialog not progress bar so we'll change it to progress dialog change the thing here also and this will be also progress dialog and now we can set a message to the Pakistan so we'll set a message like you are rich string please wait or something well damn now we'll show the progress dialog with the show method now we need our firebase authentication object so we'll define an object five is earth and to initialize this object we will use the on thread method and inside this method will write it fire this earth equals to five paise dot cat instant it will initialize our fiber South object and we can use the subject to register our user to the circle now you're right firebase auth dot create user with email and password this method takes two arguments to two string arguments first one is email and other one is password and it creates a user on the firebase console with the given email and password we can optionally attach a listener that people do right now to track the completion registration is completed or not to contact this by adding a listener so let's see how we do this so create user with email and password and write email and password here now we'll use dot add on complete listener and this listener will take the current activity context we can use it this and then the listener you on complete listening and this listener will execute this method on complete when the registration is completed and for the task object that you can see over here we can know the registration is successful or not so here we'll write if task is successful that means the task is successful so we can display a message here that you are registered successfully and anything like that and when the user is a wrister user is logged in also so we can start the profile activity here for now we are displaying only a message with toast so in the next tutorial we'll create file activity and do other things right now let's display a toast only that registered successfully oops and in else we'll write that fail to register or something like that could not register be straight now the code is ready let's try running the app you you so this is our app and we'll put our email and password and we'll tap on registered user and we got the message registered successfully now let's check on our app that the user is added or not so we'll go to the app and then click on earth and we can see the registered users here so it is loading with my practice working slow and here is the email that we just restored from the app and it is stored on the server on our firebase console so it is quite easy we haven't done anything on server-side like PHP coding or creating MySQL database it's super cool and easy there are new features on firebase like real time database cloud messaging and many more in this video we just learned firebase authentication to register users in next video we will see login and other basic things that a user needs in the app and in the whole series I'll be covering about all the firebase features so stay tuned for more tutorials and yes please do like and share this video and also don't forget to click on the subscribe button see you next time
Info
Channel: Simplified Coding
Views: 478,901
Rating: undefined out of 5
Keywords: firebase android tutorial, firebase, firebase authentication example, android firebase, firebase android, android user registration using firebase, firebase authentication tutorial
Id: 0NFwF7L-YA8
Channel Id: undefined
Length: 22min 3sec (1323 seconds)
Published: Wed Jul 13 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.