Android Real Time Chat Application Using Firebase Tutorial

In this tutorial you will learn to build an android real time chat application using firebase database.

Before reading this tutorial I hope you are already familiar with basic read and write operations on firebase. If you don’t know then I would recommend you to follow below link to get basic overview about firebase.

Read: https://firebase.google.com/docs/database/android/start/

I have developed a very basic and simple chat app in which user can login and register in the system and can do one to one chat with other users.

Android Real Time Chat Application Using Firebase Tutorial 1

Video Demo

Watch below video to see how the app works.

Android Real Time Chat Application Using Firebase Tutorial

Firebase

Go to firebase console and create a new project.

Link: https://console.firebase.google.com/

Select Database option in left sidebar. The database structure used in this project looks as shown in below image.

Android Real Time Chat Application Using Firebase Tutorial 2

In my case the database base url is https://android-chat-app-e711d.firebaseio.com/. It will be different in your case so make sure to change the url wherever used in the code.

You can access the child in form of json data by just adding .json at the end of parent url. For example in this app I have accessed users data by url https://android-chat-app-e711d.firebaseio.com/users.json.

Read more about it here https://firebase.google.com/docs/reference/rest/database/

Android Studio

Create a new android studio project with package name com.androidchatapp

Now add dependency for firebase database and volley in build.gradle (Module: app) file. Add following lines under dependency section and sync the project.

Add internet access permission in AndroidManifest.xml file.

The android studio project has following structure.

Android Real Time Chat Application Using Firebase Tutorial 3

Add following code in respective files.

AndroidManifest.xml

rounded_corner1.xml

rounded_corner2.xml

activity_chat.xml

activity_login.xml

activity_register.xml

activity_users.xml

message_area.xml

Chat.java

Login.java

Register.java

UserDetails.java

Users.java

 

Screenshots

Android Real Time Chat Application Using Firebase Tutorial 4 Android Real Time Chat Application Using Firebase Tutorial 5

Android Real Time Chat Application Using Firebase Tutorial 6 Android Real Time Chat Application Using Firebase Tutorial 7

You can download the apk and source code from below link.

Apk: http://www.mediafire.com/file/jwurkc69pag2u6w/Android+Chat+App_V1.0.apk

Source Code: http://www.mediafire.com/file/djl5s58sbw5kpma/AndroidChatApp.rar 

Feel free to ask your queries by commenting below.

7 thoughts on “Android Real Time Chat Application Using Firebase Tutorial

  1. nisha

    I want your help for my final year projetc…and the question is how to fetch active process in android phone to database

    Reply
  2. Devesh

    registered but cant log in….. user not found error

    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e453dc0, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1932470
    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e453dc0, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa19309c0
    V/FA: Activity paused, time: 1284458
    V/FA: onActivityCreated
    V/FA: Activity resumed, time: 1284528
    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e453f20, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9fdf8070
    D/InputEventConsistencyVerifier: KeyEvent: ACTION_UP but key was not down.
    in android.support.v7.widget.AppCompatEditText{26e9ba7 VFED..CL. .F….ID 42,746-1038,864 #7f0b005e app:id/password}
    0: sent at 1291504000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=1291504, downTime=1291504, deviceId=0, source=0x101 }
    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9ec14de0, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9fdf8230
    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9ec14de0, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9fdf8230

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *