One of the core benefits of Java, or to be more accurate, of the JVM (Java Virtual Machine), is the garbage collector (GC). We can create new objects without worrying about freeing them up from memory. The garbage collector will take care of allocating and freeing up the memory for us.

Not exactly! We can prevent the garbage collector from freeing up the memory for us if we do not fully understand how the GC works.

Writing a code without a good understanding of how the GC works could make memory leaks in the app. …


What is PowerPreference?

A Powerful library to control and simplify the usage of shared preference in android which provides utility on top of Android’s normal SharedPreference class.

How does it work?

So simple if you want to access preference file there is two option.

  1. Default preference file.
Preference preference = PowerPreference.getDefaultFile();
  1. Specific preference file by name.
Preference preference = PowerPreference.getFileByName("name");

There is no need to pass context the library uses a provider to catch the context when the application is start.


With the announcement of Android Oreo, Google focuses on giving the users an extensive suite of customization, they have taken a step further with two new capabilities: notification channels and notification dots. Everything was running great on the app until I started getting bad feedback.

Last week I got some negative reviews and feedback about a strange issue, the users complained that the app makes the phone restart.


Follow a standard coding style in android, it will be easier for you and also for others to understand your code easily.

I encourage you to fork this guide and change the rules to fit your team’s style guide. Below, you may list some amendments to the style guide.

#Naming

Classes & Interfaces

Written in UpperCamelCase

BAD:

interface onClickListener

GOOD:

interface OnClickListener

Methods

Written in lowerCamelCase

BAD:

public void SetValue(){
}

GOOD:

public void setValue(){
}

Fields

Written in lowerCamelCase.

public int publicField;
private int privateField;
private static SingletonClass singleton;
  • Static final fields should be written in uppercase, with an underscore separating words
public static final int THE_ANSWER = 42;

Updates:

If you still using the Hungarian Notation in your filed naming convention take a look at this…

Ali Asadi

Android Engineer | ali-asadi.com

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