Android knowledge points finishing (1)

"Android Advanced Advanced" study notes the
first basic chapter


Chapter 1: Android touch event delivery mechanism

1.1 Types of touch events

  • ACTION_DOWN
  • ACTION_MOVE
  • ACTION_UP

1.2 The three stages of event delivery

  1. Dispatch:dispatchTouchEvent
  2. Intercept:onInterceptEvent
  3. Consume:onTouchEvent

Three categories with event handling capabilities:

  1. Activity: There is dispatchTouchEventand onTouchEventmethod
  2. ViewGroup: Yes dispatchTouchEvent, onInterceptEventand onTouchEventmethod
  3. View: There is a dispatchTouchEventsum onTouchEventmethod

Chapter 2: Android View drawing process

2.1 The overall process of drawing

Starting from the root view (ViewRoot) performTraversals()method, traverse the entire view tree from top to bottom.
The view drawing is divided into three steps:

  1. Measure
  2. Layout
  3. Draw

Chapter 3: Android Animation Mechanism

3.1 Frame Animation/Drawable Animation

Using the visual persistence effect of the human eye , for a series of pictures, specify the picture and duration corresponding to each frame in the animation.

3.2 Tween Animation

You only need to define two key frames at the beginning and end of the animation, and specify the time and method of the animation change. The Android system implements a smooth transition by inserting a gradient value between the two key frames.
Includes four basic effects:

  1. Transparency change: Alpha
  2. Size change: Scale
  3. Displacement change: Translate
  4. Rotation change: Rotate

You can also combine the effects of these four weeks (Set)

3.3 Property Animation

Introduced in Android 3.0, it is equivalent to an enhanced version of the tween animation.

3.4 Transition Animation

Introduced in Android 4.4, it is essentially attribute animation.

Chapter 4: Detailed Explanation of the Use of Support Annotation Library

  Support Annotation Library is a brand new function package introduced from Android Support Library 19.1. It contains a series of useful meta-annotations to help developers find possible bugs during compilation.

Chapter 5: Detailed use of Percent Support Library

  In August 2015, Google released a new percentage layout compatible function library: Android Percent Support Library, which can solve the problem of mobile phone screen fragmentation. Currently, RelativeLayout and FrameLayout are supported. There is open source code for LinearLayout percentage layout on GitHub.

Chapter 6: Detailed Use of Design Support Library

  The Design Support Library is a new compatible function library released on Google I/O 2015, which enables developers to achieve the effect of Material Design on Android 2.1 (API Level 7) and above devices.
  This library provides a series of controls: Snackbar, Navigation View, FloatActionButton, CoordinateLayout, CollapsingToolbarLayout, etc.

Chapter 7: NDK Development in Android Studio

  ABI, Application Binary Interface, application binary interface, it defines how the binary file (refers to the .so file on the Android platform) runs on the corresponding system platform.
  Currently, the Android platform supports 7 different CPU architectures, and each CPU architecture corresponds to an ABI.

  There are two ways to add C/C++ code to the project in Android Studio:

  1. Introduce pre-compiled binary C/C++ function library

  2. Compile directly from C/C++ source code

Chapter 8: Gradle must know and know

  AAR (Adnroid Archive) is a brand new file type introduced in Android Studio. It is essentially a compressed package that contains jar files and Android-related resources.

Chapter 9: Package and publish function library to JCenter and Maven Central through Gradle

  Maven is a popular build tool in Java development. One of its benefits is that it can reduce the number of software builds that are relied on when building applications. The recommended way for Maven is to store all software builds in a remote repository called Repository.
  There are currently two standard Java & Android Maven repositories: Maven Central and JCenter.
  The early version of Android Studio used Android Maven as the default Maven repository, which has now been changed to JCenter.

Chapter 10: Detailed Explanation of Builder Mode

Refer to this article: Use Builder to solve the problem of too many constructor parameters

Chapter 11: The Application of Annotation in Android

  Annotation is one of the characteristics of the Java language. It is a label inserted in the source code. These labels play a certain role in the subsequent compilation or running process. Each annotation must @interfacebe declared through the annotation interface , and the method of the interface corresponds to Annotated elements.

1. Standard annotations

  1. Compile relevant @overridenotes: @Deprecated, @SuppressWarnnings, @SafeVarargs, @Generated, ,@FunctionalInterface

  2. Resource-related @PostConstructnotes: @PreDestroy, @Resource, ,@Resources

  3. Yuan @Targetnotes: @Retention, @Documented, @Inherited, ,@Repeatable

2. Annotation at compile time

3. Run-time annotation

Chapter 12: Analysis of the causes and positioning of AND

  ANR (Android Not Responding, the application does not respond) is a unique concept in Android.

1. The cause of ANR

  There is only one reason for ANR: the UI thread of the application has responded to a timeout, and there are generally two reasons for the timeout:

  1. The current event has no chance to be processed. For example, the UI thread is responding to another event, and the current event is blocked for some reason.

  2. The current event is being processed, but it cannot be completed in time due to the time-consuming process.

2. The root cause of ANR and the timeout period

  1. KeyDispatchTimeout: The most common type, the reason is that View OnClick()events or OnTouch()events cannot be responded to within a specific time (5 seconds).

  2. BroadcastTimeout: The reason is that the OnReceiver()method of BroadcastReceiver runs in the main thread and cannot be processed within a specific time (10 seconds).

  3. ServiceTimeout: A type that rarely occurs because the life cycle functions of the Service cannot be processed within a specific time (20 seconds).

Chapter 13: Android Asynchronous Processing

  Inheritance tree of asynchronous processing technology in Android:

Asynchronous processing technology inheritance tree in Android

1、Thread

  The various types of threads in Android applications are essentially based on pthreads of the Linux system, and can be divided into three types of threads at the application layer:

  1. Main thread: UI thread, which starts with the start of the application. The main thread is used to run Android components while refreshing UI elements on the screen. Only the main thread can operate the UI because Android's UI toolkit is not thread-safe. The Handler worn in the main thread will sequentially execute the received messages, including messages sent from other threads.

  2. Binder thread: used for thread communication between different processes. Each process maintains a thread pool to process messages sent by threads in other processes. In most cases, the application does not need to care about the Binder thread, because the system will preferentially convert the request to use the main thread.

  3. Background thread: All threads created in the application display are background threads. At the Linux system level, the main thread and the background thread are the same. In the Android framework, WindowManager is given the restriction that the main thread can only handle UI updates and the background thread cannot directly manipulate the UI.

Chapter 14: Research on Android Data Serialization Scheme

  序列化是将数据结构或者对象转换成可用于存储或者传输的数据格式的过程,在序列化期间,数据结构或者对象将其状态信息写入到临时或者持久性存储区中。

1、Serializable

  Serializable是Java语言的特性,它是最简单的也是使用最广泛的序列化方案之一。它的缺点是使用反射机制,在序列化的过程中会创建很多临时对象,容易触发垃圾回收,序列化的过程较慢,对于性能要求很严格的场景不建议使用这种方案。
  Serializable是JDK提供的接口,其序列化方式是基于磁盘或者网络的。
  对象的序列化是基于字节的,因此不能使用Reader和Writer这种基于字符的方式。

2、Parcelable

  Parcelable是Android SDK提供的接口,其序列化方式是基于内存的。由于内存读写速度高于磁盘,因此在Android中跨进程对象的传递一般使用Parcelable。

3、SQLiteDatabase

  SQLite是一款轻量级的关系型数据库,运算速度快、占用资源少(只需要几百KB内存),特别适合在移动设备上使用。Android和iOS都内置了SQLite数据库。

4、SharedPreferences

  SharedPreferences是Android平台提供的一个轻量级的存储API,一般用来保存应用的一些常用配置信息,其本质是一个键值对存储。SharedPreferences相比其他序列化方法更高效。

5、JSON

  JavaScript Object Notation,是一种轻量级的数据交换格式,几乎80%的APP与服务端的通信都是使用JSON格式。

6、Protoclo Buffers及Nano-Proto-Buffers

  Protoclo Buffers is a lightweight and efficient serialized structured data storage format designed by Google that is language-independent and platform-independent, similar to XML, but smaller, faster, and simpler. It is best to use the Nano-Proto-Buffers
version in the mobile code .

7、FlatBuffers

  FlatBuffers is an open source, cross-platform, and efficient serialization library created by Google for game development or other performance-sensitive applications. It provides support for language interfaces such as C++/Java. FlatBuffers is a serialization library that focuses on performance and resource usage. Compared with Protoclo Buffers, FlatBuffers is more suitable for mobile devices.

Android WebView Java and JavaScript exchange detailed explanation

  Almost all mobile applications nowadays are Hybrid, which combines the advantages of Native APP and Web APP, which not only guarantees the user experience, but also enables the APP to have the ability to dynamically update to a certain extent. At the same time, it is conducive to cross-platform development and reduces manpower. cost.
  The key to Hybrid is to realize the communication between Java and JavaScript, that is, Java calls JavaScript, and JavaScript calls Java.

Guess you like

Origin blog.csdn.net/michael_f2008/article/details/77895701