159 Followers
·
Follow

Image for post
Image for post

One of the core benefits of Java that she is a garbage-collected language. That means we can create objects, and the garbage collector will take care of allocating and freeing up the memory for us.

Although we have the garbage collector, unfortunately, we can prevent him from doing his job by making some code mistakes. Those mistakes are causing memory leaks. The leaks can affect our android app by wasting unreleased memory and eventually causes to out of memory exceptions and lags.

What is Memory Leak?

Failure of releasing unused objects from the memory

That means there are unused objects in the application that the garbage collector cannot release from memory. So the memory unit is occupied until the end of the application/method. …


Image for post
Image for post

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.

Image for post
Image for post

Before moving to save and getting preferences. Let us check which data we can store in preferences

  • Int, Long, Float, Double, String, ArrayList, Map, Object.

Save Data

To Write data to preference file all you should do is to call put method with key and value that you want to store in the file. …


Image for post
Image for post

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.

Image for post
Image for post

In the beginning, it sounded illogical having this issue in the production. Indeed we have 100,000+ monthly active users and just a few of them actually reported this problem. But the users are always right! So we gave a high priority to solve the problem and be able to answer the users ASAP. First of all, we collected the needed data in order to reproduce the problem and to understand what happened to these users. …

About

Ali Asadi

Android Engineer | aliasadi.info

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