Skip to main content

Posts

Event Bus in Android with Example | Simple and Easy Tutorial to Get Started

EventBus is the number 1 event library for android and java. EventBus uses the publisher and subscriber pattern for loose coupling which means the possibility of errors will be less. EventBus simplifies the communication between different components for example communications between different levels of activities or even services. You need very less or no setup to use EventBus in your existing project.  EventBus provides a convenient annotation-based API which makes it fast and the performance is increased. EventBus is used by many popular apps, apps which has 1 billion-plus download which shows how EventBus popular. In this tutorial, we will see how we can get started using EventBus in an android project. Before jumping in the code let's see what we will be going to make. To better understanding EventBus we will make an app that allows us to add items to the cart and show the total count of the items. See below how our app will work. Let's

Top 10 Libraries every android developer should know [Best For Beginners]

Hello world, today we are going to see the top 10 libraries for the android developer that they should know about. You can use these libraries or you can also use their equivalent libraries if you like. These top 10 libraries are based on my experience this list can be different from person to person. The top 10 libraries every Android developer should know are listed below. Fast Android Networking Library Glide Room Persistence Library Firebase Cloud Firestore Crashlytics LeakCanary ExoPlayer Firebase Auth Firebase Storage Facebook Shimmer 1. Fast Android Networking Library Fast android networking as the name suggests this library is used for making HTTP requests. But what makes this library stand out of other libraries is its simplicity of use that everyone can start using it without any other requirement or follow any pattern. Just add this library to your project and start using it. It uses OkHttp and Okio which

Upload Image to Firebase Storage | Android Tutorial

How to upload Image to Firebase Storage in Android Hello world, today we are going to learn how we can  upload an image to the firebase storage  from our android application. We will see how we can  show the progress of uploading an image to the user. Firebase storage  gives use utility to upload the file and get the URL of that uploaded file so that we can access our file through the link. Let's see the final result we are going to learn. Before staring the code we need to enable firebase storage in our Firebase project. Open your Firebase console and select the project and click on storage then follow the on-screen instructions. After creating the storage we need to change our storage rule so that we can access the storage with the authentication. Open your rules and change the if condition and replace != to ==. After make changes hit the publish button and we are ready to go. In your android project add these dependencies to work with

How to change font family of textview.

How to change font family of textview Hello world, today we are going to see how we can set the different font families to the textview. Why we need to use a different font for textview because simple or default font family of textview looks so simple and to give a professional look to our app we need custom fonts for textview. Let's see how to add custom fonts in the android application. Below is the example of the custom fonts added to the textview. In the above image first font is default one and the rest are custom added fonts. To add the fonts first we need to download the .ttf files. Download .ttf fonts for textview You can download fonts(.ttf) from here  https://fonts.google.com/ Download one or more fonts that you like to add in the app. Create a font folder and add fonts After downloading we need to add these fonts in the font folder in the android project. To make the font folder right-click on res folder then

Bottom sheet in android | Android Tutorial 2020 Updated

How to make Bottom Sheet in Android Hello world, today we are going to see how to make a persistence bottom sheet and how to make a modal bottom sheet in the android . The bottom sheet has two types, one is persistence and the second is a modal sheet. In both cases, the bottom sheet slides up. In the persistence bottom sheet, some parts of the bottom sheet showing to the user so that the user can slides up and in the model bottom sheet you can make a trigger to show the bottom sheet and it is fully hidden unlikely persistence bottom sheet. When a user clicks on a button or something you can trigger the modal bottom sheet to show. Let's see the finished app which we are going to make below. Before making any type of bottom sheet we must add the dependency. Add Bottom Sheet Dependency in Android Project Let's first make a persistence bottom sheet. How to make Persistence Bottom Sheet First, we need to make our layout for the bo

How to make Tabs with swipeable view in Android [2020]

Make Tabs with Swipeable Layout using ViewPager2 and TabLayout Hello world, today we are going to see how to make a swipeable view using ViewPager2 and TabLayout. We will see how to use fragment and how to sync tab layout indicator with ViewPager2 swipes. We will set the tab layout title to the tabs and then inflate our views in viewpager. Let's look at the finished app in the below gif. To make the swipeable views, first, we need to add a required dependency for our project. Add Dependency for TabLayout Open your build.gradle file app level and in the dependency section and add these dependencies. We need this dependency to use TabLayout. After adding and syncing the project. Let's add TabLayout and ViewPager2 in our activity XML file. Add TabLayout and ViewPager2 in Activity XML Add the below code in the activity_main.xml or your activity xml file. In the above code, we have added the TabLayout with some attributes pro

Firebase Cloud FireStore Database in Android | Beginner Android Tutorial

How to use Firebase Cloud FireStore Database in Android Hello World, today we are going to see how we can make a todo app using a firebase cloud firestore database . The  Firestore database  is a very flexible and scalable NoSQL database to make our development very fast. Firestore is very easy to use in android. FireStore can work smoothly even if your device is offline it can fetch data from the cache in the device so that your app can work offline and update the data when it connects to the internet again. This functionally makes your app for interactive for the users. Firestore database has one more feature is to watch realtime changes in the database and you can show updates in the app.  Firestore database can execute queries so that you can filter your data as per your requirement, this feature makes the firestore database more likely to choose for your project.

How to make Dark (Night) Mode Theme in Android | Android Tutorial

How to make Dark (Night) Mode Theme in Android Hello World, today we are going to see how we can  implement a dark theme or night mode in our android application. This tutorial is going to be very simple and easy to understand. The dark theme is attractive to users and it is comfortable for low light conditions. Recently many apps adapt dark mode in their app and the output of the  night mode is amazing as many users love dark mode for their app. An example of a dark theme is Whatsapp dark mode in android see the below image. Let's look at how our app will look like, see the below gif for our end result app. Let's see how we can implement dark theme in our app. Make layout for dark theme First, we need to make our layout so that we can apply our dark theme to it. If you see the above gif we used cardview to make our layout. See the below code for layout. Now we need to set theme colors in the layout, for example, we