Optimize your Android app’s memory consumption with profiling in Android Studio

What is App Profiling, and how can it help?

One question app developers must ask themselves is: What am I going to do when users communicate that they feel laggy while using a given app? The answer isn’t always immediately clear, but most of the time it has to do with CPU-intensive tasks that block the main thread, and there are also cases where these kinds of performance issues are related to memory.

You can, of course, print some logs to help you troubleshoot, but you need to be quite familiar with the codebase in order to put the log in the appropriate places.

If you want to explore…


HTTPS and SSL Pinning

There are two major factors in an HTTPS connection, a valid certificate that server presents during handshaking, and a cipher suite to be used for data encryption during transmission. The certificate is the essential component and serves as a proof of identity of the server. The client will only trust the server if the server can provide a valid certificate that is signed by one of the trusted Certificate Authorities that come pre-installed in the client, otherwise, the connection will be aborted.

An attacker can abuse this mechanism by either install a malicious root CA certificate to user devices so…


We all love MacBooks, the macOS is fast, highly optimized for the hardware and constantly updated by Apple. However, there are times when we need to use Windows OS for tasks that cannot be completed with macOS, like using Windows-only software and playing PC games. The most common ways of using Windows in MacBook are either having a Virtual Windows Machine or installing a guest OS on top of your MacBook via the Boot Camp Assistant. I am not a fan of these two as either solution will consume a certain amount of my precious SSD.

In this article, I…


Maybe one day we’ll all put filters on our fruit, too…

At I/O 2018, Google announced the release of Firebase’s ML Kit, a developer-friendly software package that allows mobile engineers to quickly integrate Machine Learning features in their applications with just a few lines of code. With ML Kit, we’re able to do amazing things like face detection, text recognition, and landmark recognition, all without needing to have deep knowledge about neural networks or model optimization.

In this article, I’m going to show you how to make a working Snapchat Filter Android application in 7 steps. You can find the example code in this GitHub repo — all PRs are welcomed.


Credit: https://javarevisited.blogspot.sg/2013/06/why-favor-composition-over-inheritance-java-oops-design.html?m=1

Composition over inheritance is an important principle in Object-oriented programming. Instead of implementing all the functionalities of desired interfaces inside one monolithic class, these functionalities should be implemented independently in various instances, and then use these objects to eventually empower the target class with all the provided functionalities. This principle make the code more reusable and maintainable.

The Example

Let me explain the idea in a simple example. Imagine you are working in a automobile company, and your job is to manufacture cars based on various requirements like the color of the car (appearance), the max speed (performance), and the number of…


With the exponential growth of computation power and the adoption of the Artificial neural network, Machine Learning has quickly become a trend in the industry recently. There are many open source tools available for us to start Machine Learning, TensorFlow from Google outstands them and has gained huge popularity among the researchers and engineers, with the release of TensorFlow-lite, the mobile-friendly version of TensorFlow, we are able to perform complicated tasks, such as image recognition, right inside the mobile devices without external resources. If you do not have a Ph.D. background like me, and yet are interested Machine Learning with…


Why MVVM?

When we first start Android development, it is very common to begin everything from Activity class, because it is the entry point to Android application and the first chapter from the getting-started guideline. We start with inflating UI in Activity, declaring UI control objects and it just becomes natural to handle UI events such as button clicking, scrolling and swiping in the same Activity. When it comes to the time when we need to retrieve data from remote or local source and display in the UI, we look no further than Activity. …


If Java is your first programming language, most likely you will take memory management for granted and let the built-in JVM Garbage Collector from JVM to do the job. It is probably doing fine in most cases, however there are some scenarios where unexpected memory leak could happen.

How does Garbage Collector determine whether the memory of a object can be freed? If a object has no other references point it, then it is marked as a candidate to be Garbage Collected. …


Source: http://howto.caspio.com/localizations/handling-arabic-hebrew-and-other-right-to-left-languages/

While most of the languages in the world are written from left to right, there are several languages are written in Right-to-Left writing (RTL) system. The most widespread RTL are Arabic script, Hebrew alphabet and Syriac alphabet.

Android has full native support of RTL layout/text orientation since SDK 17 (Android 4.2 Jelly Bean), according to the official blog, getting started is easy.

  1. Set targetSdkVersion or minSdkVersion to 17 or higher in the uses-sdk tag of AndroidManifest.xml
  2. Declare android:supportsRtl=”true” in the application tag of AndroidManifest.xml
  3. Replace all the occurrences of layout attributes that contains ‘left’ and ‘right’ to ‘start’ and ‘end’…

Zhang QiChuan

Software Engineer — Singapore

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