Drew shapes in one custom view, and found there are 68 thousand "Point"
objects in the memory after a while, and got an ANR for that. How to
troubleshoot and fix it?
3D ball is a custom view which rotate and show tags in 3-dimensions.
However, most frames are over 16ms, which is bad for performance. How to
RxJava and Kotlin are new technic in 2015 - 2016. And I found out a memory
leak when I tried to use them.
Activity Launch Mode can be confusing. It is pretty hard to understand if
you don't know how to apply them to the real-life project. This post shows
the examples and help you understand the four launch modes.
One of the third-party library which reference one Activity caused a
memory leak in my project. How to fix it?
This series lists all the possible way to leak memory, which you should
avoid to do in your project. This post is about registering a resource.
This series lists all the possible way to leak memory, which you should
avoid to do in your project. This post is about anything that last longer
than your activity, like static variable.
Using launch mode without cautiousness result in bugs. I had such one in
my project. It's an Activity with multiple Fragment, and it use CLEAR_TOP
I've tried several approaches to optimize the code: Method count, Enum,
Serializable, Inheritance Hell, MVP, Test
This functionality includes two issues:
(1). create a floating window which is backward compatible;
(2). how to get to know if my app is displaying at a time?
1). static reference to a Context
2). Client session out
1). UI rendering
2). Abuse of onResume
3). Speed up the build
A typical scenario when using HTTP request queue. How to handle the
important, latest or canceled request?
I have been made a scratch card in app in 2014. It worked mostly okay. But
I still have one issue. Two years later, 2016, I finally fixed this bug.
This blog will show you how to draw different layer in a view, and the
clear effect in the canvas.
This is the part two of canvas introduction. Canvas API on Android is a
helpful tool in some specific occasions.
ActionSheet on iOS is used to display a set of menus from the bottom. It's
like Android's dialog, just from the bottom.
These two methods are confusing concepts for lots of new developers. Hope
this post will help you.
Touch Event system is complex and confusing, but it is also extremely
important to draw any View with gestures. Xiaolin, a colleague of mine,
summary all different occasion in one single picture. With this picture,
it should be easy to find out what you need.
Drag and Drop in one View could be done by 1). Drag&Drop API on Android;
2). ViewDragHelper. But if you want to achieve drag&drop across two
different group/list, it would be hard to do since we don't have such API.
This actually is a problem that I was asked when I was interviewed by one
Company. I answer it quite correctly. After I came back, I wrote some code
to implement it.
Epoxy is a library about RecyclerView. However, its original sample is
quite hard to grasp. Here I want to make this integration to Epoxy be
easier for you.
Use fingerprint in Java would not be an easy job. A lot of callbacks,
different code in different palces(, like startActivityForResult() and
onActivityResult()). However, Kotlin can be a saviour.
Just like fingerprint API, requesting permission dynamically on Android
could be hard to write and read. I saw a couple of libraries try to solve
this by using inheritance. However, I solve this problem by using
Quite a lot of developer complaint about writing test. It's slow and
seemingly useless. However, test could find the bug for you, especially
after your refactor. Test could also make your architecture better.
I've made a SDK which needs to load imagers from server. However the
client of our SDK may have different ImageLoader library, such as UIL,
Picasso, Glide or Fresco. How could we add an image loader library without
adding more burdern to our client.
MVVM is another pattern which is good for test and separation. Normally
you could use RxJava, or data-binding to implement a MVVM pattern.
MVP is a good pattern to help you design better. However, there are still
some questions about MVP, especialy for the junior developers.
When you need to design a global lifecycle system, you may need to hijack
the lifecycle of Activity. Here I offer three approach to achieve this.
Lifecycle library is a good library. However, I get to know some tricky
issues about it, and here I want to share them.
If you were using the alpha or beta version of Lifecycle library, you
definitely need to see this post when you switch to the stable version.
ViewModel is a new library for Android dev which helps your class survive
configuration change. And also it is a good option if you are using MVVM
After using LiveData and ViewModel for more than three months, I am not
totally satisfied with these two libraries. I think there are some
disadvantage that worth discussing in this post.
Android just released one new Library : WorkManager in this year's Google
I/O. Let's have a look.
Open Source Library
AutoGo is a libray to help you navigate to another Activity elegantly.
This is another lecture about making an annotation library.
Comparing to EventBus2, EventBus3 is using runtime annotation, which
definitely slows down the speed. How come EventBus has a better
performance than EventBus2?
Hugo is a good library to help us debug. Digging into this library and we
would learn a lot. However, we can still improve it by using Gradle's
This is a slight improvement if you don't want people to see the source
code of your project. Of course, you still need proguard.
Android 6.0 has a new API about fingerprint. If you want to save something
that can be accessed by your fingerprint, you may need the FingerPrint API
and also the KeyStore API. This post just shows you how to do that.
This is a post about how Https works. It's totally theoretical, but it
shows you in a picture that you would understand it very quickly.
Some tips about Android Security
I just talked about Https in the last post. Here is one attack on Https
you may encounter in your development.
Android project is hard to test. But it is not an excuse not to test it.
Let's explore the test world for Android.
A clean code base must to be a project that is friendly to test. Let's see
how to build a clean project friendly to test.
Google has a TODO-MVP sample project, which is good presentation of how to
architectu better. This article tries to analyze how it test its code.
Test sometimes is hard. Test a Singleton is especially hard. How do we
We actually could test Kotlin project in Java. This is merely the
conversion between Kotlin and Java.
Introduction to another expresso tool: Espresso Test Recorder. It's still
in its beta. But you could take a look. It helps you do your tests
Of course, we can write Kotlin code to test your code. Yes, JUnit is still
working. So don't worry about it.
If you want to unit test your Activity, one huge challenge you may have is
how to inject your mocked Presenter object in your test cases. The
difficulty is the Presenter instance is initialized in the
Activity#onCreate(), and it's hard to inject your mocked instance.
ROOM is another Android Architecture Component library. And you should
write unit test to make sure the database manipulation is workign as you
Espresso is great for your intergration test. But there are some pitfalls
you may get as well. This article tries to help you to avoid these
What is lambda? And what is the implementation of lambda in the level of
Java Access Modifier seems easy and basic, but sometimes you may get
confused. Here is an example of how I work around it to make my dev life
Kotlin, a new language invented by JetBrains. You may find it is even sweetier than you think.
the sweetness of kotlin
NDK is a powerful tool when developing one Android app. So how kotlin cooperate with NDK?
kotlin can implement extensions, even to system classes, just like Ruby. So, how kotlin does it? What's the secret under the hoold. Let's take a look.
kotlin tips 1/N
RxJava & RxJava In Android
You could input multiple characters in EditText. And we may have some unique verfication about the input. RxJava is a powerful tool that may help us.
introduction of throttle, debouce, combineLatest. p.s. If you are a redux-saga user, you may find it familiar as well.
React, React Native
This post is mostly from my own experience, and is good for anyone who
want to learn React Native, especially for the native mobile developers.
Hope this post can help you get into the world of React Native smoother.
This post shows some examples about writing HoC, render props, to help you overcome some TypeScript erros you might have.
This post is not a API reference of saga, but a post to introduce why we need saga, and how saga works under hood. This is perfect for someone who have used saga, but don't understand saga well.
With types, TypeScript make the react/react-native development much safer. But TypeScript is not that easy to write, and you may have this or that kind of issue once a while. This post gives you some tips that make your TypeScript development smooth.
Meeting is useful for communication. But we've all benn in a lot of long, tedious meeting. How do we host an effective meeting?
test, a tool to make your life easier.
I list some books that is helpful to me. Hope it helps you too.
How to have an efficient stand-up meeting?
Making a good on-boarding guide
How to recruit the right people?
[Tool] Translate json to java POJO classes
[Tool] Generate Activity class from layout xml file automatically
Writing a tool to get english script
[Tool] Introduction to The Activity Template in Android Studio
Android Studio does not recognize my cellphone?
Using Node.js to deploy a fake server to speed up your development