Photo by Kyle Glenn on Unsplash

As I started refactoring one of my Android projects, I came up with the dependency injection part which used Dagger-Android. Since it’s been recommended not to use it anymore (I’m not going to the details here!) I replaced it with the pure Dagger.

Here I’ll show it with very simple steps! 🤩

First of all, you need to change the Dagger dependencies. You can get rid of those android ones like the below snippet:

Now let’s change your base application class which is called App inside my project. In the Dagger-Android we used the DaggerApplication() but for Dagger…


Photo by Denny Müller on Unsplash

The Context in Android is one of the most important objects and actually is the Context of the current state of the application with major responsibilities such as:

  • Getting information regarding the activity and application.
  • Getting access to the database, application-specific resources (strings, drawable, …) and classes, filesystems, and shared preferences.
  • Up-calls for application-level operations such as launching activities, broadcasting, and receiving intents.

As you can see, almost everything in Android needs access to Context, so if we use it wrong, it can lead to memory leaks. Mainly there are two types of Context:

  • Application Context: This Context is bound…


Photo by Cookie the Pom on Unsplash

If you are getting data by using a web service, you should wait until the data is successfully fetched (or even if it’s not successful) then take your next action. How would you implement it? Maybe by using an OnDataLoadedListener ?🧐.

The custom listener (listener/observer pattern) is used to emit events to a single parent for the purpose of communicating information asynchronously in order to run the code when an event occurs which helps us to move complicated logic out from our code. This Java pattern can be used in so many cases such as the communication from a fragment…


Photo by Matthew Henry on Unsplash

This article is about the Parcelable interface in Android. I will start with a short definition of it and then implement it using Java and Kotlin. In the end, I will show you how to add it as a plugin in the android studio. So let’s start with this article 👏🏻 …

What is Parcelable?

With the help of Parcelable, we will be able to pass object references between components of the application such as activities using the intent. However, there is another approach called the Serialization which will be enabled when a class implements the Serializable interface, but it uses reflection and…


Photo by Med Badr Chemmaoui on Unsplash

In this article, I will show you how to create a custom Toast that can have a custom layout. Then we end up with some libraries that help us o create different custom Toast messages like success, error, info Toasts, and Etc.

Create a Custom Text for Toast:

The Toast class uses a TextView object for showing a message so that if we have access to it, we will be able to change the text as we want. …


Photo by Juan Gomez on Unsplash

You might have heard of Data Binding. It is a library as part of the Android Jetpack that binds UI components to data sources in the XML layout and minimizes the required code for the application’s logic. It has the ability of automatic UI update whenever data is changed and you can say goodbye to the very familiar findViewById🤗 … so more than code readability it helps to reduce null pointer exceptions and memory leaks, but consider that the errors will be caught in the compile-time. Although the layout expression language gives you a lot of power, it is best…


Image Source: https://www.wlion.com/blog/5-reasons-you-should-be-writing-clean-code/

In this article, I’m going to talk about writing clean code in general and then end up with some examples. As an Android developer having a clean code has always been challenging for me which needs lots of effort and that’s just coding and coding 💻 …

Rules We Should Follow

  1. Ignore duplication (imply DRY principle-Don’t Repeat Yourself)
  2. Minimize entities, classes, and functions (avoid repetition)
  3. It should be readable and simple
  4. Be testable as it makes your code flexible and maintainable
  5. Follow SOLID principles

S = Single-responsibility principle: A class should only have one purpose.

O = Open-closed principle: A class should be open…

Maryam Dashtirahmatabadi

A self-learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store