How to use Lifecycle components

2017/5/18 Google IO Android Architecture Components: a new collection of libraries that can easily manage the UI component life cycle and handle data persistence. Help you design robust, testable, and maintainable applications. In the following, the life cycle of components such as Fragment and Activity directly uses ...

Added by nodi on Sun, 03 May 2020 09:45:43 +0300

Android manually publishes an event bus framework II. Communication between main thread and sub thread on Activity

Next, we will continue to write the previous article. This time, we will use meta annotation on the receive function to distinguish which thread the receive function needs to execute on @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Process { int value() default 0; }Then add two constants to EventLine ...

Added by ThatGuyBob on Sat, 02 May 2020 17:08:31 +0300

Passing custom Fragment class specific parameters that inherit Fragment

The custom Fragment class of inherited Fragment, CustomFragment, cannot be passed by modifying the construction method like the custom Activity class of inherited Activity. So we need to implement it through bundle and instance. There are four steps: 1. Create a global variable corresponding to the parameter for use. 2. The newinstance init ...

Added by walexman on Fri, 01 May 2020 20:16:25 +0300

Several implementation methods of Android text vertical scrolling and vertical horse riding lamp

Method 1: use the system control ViewFlipper mode: Layout file: <ViewFlipper android:id="@+id/view_flipper" android:layout_width="300dp" android:layout_height="35dp" android:layout_centerInParent="true" android:autoStart="true" android:background="@drawable/warning_bg" android: ...

Added by DarkSuperHero on Fri, 01 May 2020 19:56:52 +0300

RxHttp, a more elegant protocol experience than Retrofit

1. Preface Hello, you little friends, have met again. Looking back, RxHttp We are about to have our anniversary birthday (launched in April 19). This year, we have come over with sincerity.... Sincerity is not easy. Code maintenance, writing articles, writing documents, etc. are often done after zero o'clock. It is also the first time that I sp ...

Added by Jordi_E on Mon, 20 Apr 2020 19:24:27 +0300

The difference between replace() and add() methods when Android Fragment is dynamically created

1. replace() as the name implies "replace" will destroy the existing views in the layout container, which will cause reinitialization and waste traffic every time the Fragment is switched. //Get fragment Manager fragmentManager = getSupportFragmentManager(); //Transactions cannot be shared. Each time a transaction is used, it must ...

Added by sevenmenkes on Sat, 18 Apr 2020 19:06:07 +0300

20 lines to implement a Promise

Author: dream at dawn source: gold digging   Preface During the interview, there are often interviewers who ask you to implement A Promise. If you implement it by referring to the A + specification, it may not end until dark. When it comes to Promise, the core function we first think of is asynchronous chain call. This article will take yo ...

Added by mdannatt on Sun, 05 Apr 2020 08:53:29 +0300

The problem of sax parsing xml

characters will have many problems. Record them and find them for a long time. It turns out that they are the problem of spaces. Here is the xml file after format and the corresponding print xml file: Corresponding log: Reference: the following excerpt from http://blog.csdn.net/Garmiter/article/details/8016840 XML type 1: no ...

Added by Codewarrior123 on Sat, 04 Apr 2020 14:47:05 +0300

Step by step Android general framework (3)

Custom annotation Because here to use reflection knowledge, so not familiar with the reflection of the need to review next Oh. Create a new package injection, and define the annotation class Id under the package @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface Id { /** ...

Added by aquilina on Thu, 02 Apr 2020 17:05:47 +0300

Microphone recording

Recently, I am studying speech recognition, using Baidu's sdk. It is found that only the identified part, and I need to save the audio file, and realize the automatic generation of the audio file when there is sound incoming. First code: public class EngineeCore { String filePath = "E:\\voice\\voice_cache.wav"; AudioFormat audioForma ...

Added by nashsaint on Thu, 02 Apr 2020 05:09:23 +0300