Posts

Firebase Database Example in Android

Image
What is Firebase :                  The Firebase Realtime Database is a cloud-hosted NoSQL database that lets you store and sync data between your users in realtime.The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data. NEW: Cloud Firestore (beta) enables to you store, sync and query app data at global scale. Setup Firebase Realtime Database for Android :  There are two ways you can connect your app to Firebase .     1. Install Firebase SDK     2.Using Firebase Console ,add your app to Firebase .   Install Firebase SDK : If you're using the latest version of Android Studio (vers...

Difference Between Interpreter and Compiler

We generally write a computer program using a high-level language. A high-level language is one which is understandable by us humans. It contains words and phrases from the English (or other) language. But a computer does not understand high-level language. It only understands program written in 0's and 1's in binary, called the machine code. A program written in high-level language is called a source code. We need to convert the source code into machine code and this is accomplished by compilers and interpreters. Hence, a compiler or an interpreter is a program that converts program written in high-level language into machine code understood by the computer.  Interpreter :      1. Translates program one statement at a time.      2. It takes less amount of time to analyze the source code but the overall execution time is slower.      3. No intermediate object code is generated, hence are memory efficient.  ...

Coordinator Layout in Android

Image
CoordinatorLayout is a super-powered FrameLayout.CoordinatorLayout is intended for two primary use cases: As a top-level application decor or chrome layout As a container for a specific interaction with one or more child views By specifying Behaviors for child views of a CoordinatorLayout you can provide many different interactions within a single parent and those views can also interact with one another. View classes can specify a default behavior when used as a child of a CoordinatorLayout using the DefaultBehavior annotation. Behaviors may be used to implement a variety of interactions and additional layout modifications ranging from sliding drawers and panels to swipe-dismissable elements and buttons that stick to other elements as they move and animate. Children of a CoordinatorLayout may have an anchor. This view id must correspond to an arbitrary descendant of the CoordinatorLayout, but it may not be the anchored child itself or a descendant of the anchored child. Thi...

Custom Dialog With Call Back in Android

Image
What is Dialog in Android : A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Create Custom Layout :   If you want a custom layout in a dialog, create a layout and add it to an AlertDialog by calling setView() on your AlertDialog.Builder object or add it to  Dialod by calling setContentView() on your Dialog object. . Dialog Methods : cancel() : Cancel the dialog. dismiss() : Dismiss the dialog. Removing it from screen . setContentView(int resId) : Set the screen content from layout resource. setCanceledOnTouchOutside(boolean cancel) : Sets whether this dialog is canceled when touched outside the window's bounds.  setCancelable(boolean value) : Sets whether this dialog is cancelable with the BACK key.  requestWindowFeature(int featuredId) : Enable extend...

Toast in Android

Image
Android Toast is used to show sort message. Toast message takes only that amount of space that is required to show message, and during that time activity is visible and user can interact with it. Toasts automatically disappear after a timeout.                                                        Toast Usage : We can use Toast to show sort message as follows: Toast . makeText ( getApplicationContext(), "Your Message" , Toast . LENGTH_LONG ).show(); We need to pass 3 arguments in Toast.makeText(Context context,String message,int length) function as follows: Context: First argument is Context object String: Message which you want to display in Toast. int: third parameter  is duration. It can have values Toast. LENGTH_SHORT or Toast. LENGTH_LONG Set Position of Toast :    We can change the position...