使用 Kotlin 编写 Android 应用时要注意的一个小坑

nullable 是个好东西,但可惜 Java 没有呀~

Read more   2/26/2020 posted in  Android

Android Studio 编写 JNI 代码时的一个小问题

'AttachCurrentThread' in '_JavaVM'; did you mean 'attachCurrentThread'?
auto result = JVM.load()->AttachCurrentThread(&env, nullptr);
^~~~~~~~~~~~~~~~~~~
attachCurrentThread
/opt/android-sdk/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/jni.h:1058:10: note: 'attachCurrentThread' declared here
jint attachCurrentThread(JNIEnv** p_env, void* thr_args)
Read more   6/12/2019 posted in  Android

C++ 线程多次回调 JNI 到 Java 时的一个坑

JNI 是个好东西,但是用起来千万要小心。

Read more   5/28/2019 posted in  Android

RecyclerView with SortedList

0x00 Background

It is common for a list to have a specific order, assuming you have a bunch of contacts in your list, you might want to sort them in alphabet order, or if you have some kind of notes, you like to sort them in time order. These sorting requirements are common and easy, you can just use a list and a comparator, just use the compare() method, however some are much complicated, like different kind of data, different sort rules, how to deal with the duplicated names. Also, you need to handle all the changes like insert, remove and updates. Sometimes it can be annoying, no worry, we have SortedList.

Read more   8/13/2018 posted in  Android

Android dynamic UI for phones and tablets

This is mainly for Phone UI and Tablet UI. Since Android has supported split screen since Android OS 7.0. It's not suitable to use isTablet to check whether App runs on a tablet. It might be a tablet but shows a phone UI.

Read more   6/26/2018 posted in  Android

Different ways to send problem report in app with screenshots

0x00 Requirements background

When an application released and get used by customers, crashes and ANRs are usually the most annoying issues for developers, it's hard to get the specific context of the entire usage.

Read more   4/12/2018 posted in  Android

A simple Android JankDetecter design and implementation

0x00 Background

When we developing and releasing an Android Application, we might encounter issues like Frozen Frames(FF) or Janks(according to Android Developer), to detect Janks during developing or logging, we can add a simple detector to check whether an application is going through a Jank.

Read more   3/10/2018 posted in  Android

Android App Layout performance optimization investigation

Slow rendering can cause Frozen Frames issue.
To avoid Slow Rendering issue. Try to analysis Android App with tools.

Read more   2/1/2018 posted in  Android

Android(Java) 中的单例类的实现

单例模式(Singleton) 是我们常用的一种设计模式,通常用来保证在全局情况下总是能够拿到同样的一个类实例来实现相关的工作。
单例模式很常见,因此也有戏称:

单例的写法茴香豆的的写法还多。

Read more   1/26/2018 posted in  Android

Android MediaPlayer setData 0X8000000 error

This issue might be caused by ringtone permission, if using a custom ringtone or ringtone set by other apps, must ensure your app has storage permission, otherwise, you cannot setDataUri to MediaPlayer instance.

11/28/2017 posted in  Android