Cover. PNG

preface

I often receive private messages from some students on Jianshu and wechat, saying that they will graduate soon or have graduated for one year and are engaged in work related to Android development, but now I don’t know what to learn. Or they are also groping to learn, but do not know whether the learning route is right, feel confused, want me to give some advice.

Most developers have had similar experiences (I have, too). When their project is finished and in the maintenance phase, they are busy at work and want to learn by themselves, but they don’t know what to learn. Where to start? A hammer and a stick, the final harvest is very little. Then they start to doubt themselves, get tired of learning, and fall down.

So, how do you plan your learning path as an Android developer and move up the middle and higher levels one step at a time? This article according to some of their own views comb.

First of all, Java as the first language of Android development (Kotlin popularity will take some time), if you want to play in Android development, you must first lay a solid foundation of Java, what are the Java foundation? In addition to some basic syntax, the following basics are summarized:

Java as an object-oriented programming language, you need to know the three main features of OOP: encapsulation, inheritance, and polymorphism.

2. Six principles of programming:

  • Single responsibility principle
  • Richter’s substitution principle
  • Dependency inversion principle
  • Interface Isolation Principle
  • Demeter’s rule
  • The open closed principle

It is essential to understand these six design principles to guide the design and specification of the entire structure of your application. Keep these principles in mind to improve the quality of your code. Follow these principles as we design our classes, methods, and interfaces.

3. Design patterns

  • Singleton modes: double check, static inner class, enumeration.
  • Constructor pattern
  • Template method pattern
  • Decorator mode
  • Observer model
  • Chain of Responsibility model
  • The strategy pattern

There are 23 design patterns to go, but whether you’ve been working for 5 years or 1 year, learning design patterns will help open your programming mind.

Do you know the differences between Java String classes: String, StringBuilder, and StringBuffer? This is a common interview question, if you don’t know? Well, look it up.

On the thread pool side, the JDK has several thread pools built in for us:

  • NewFixedThreadPool: creates a thread pool of fixed size, poolCoreSize is equal to maxPoolSize, and when coreSize is reached, new tasks are placed in the cache queue.

  • NewSingleThreadExecutor: newSingleThreadExecutor creates a single-threaded thread pool with a core pool size and a maximum pool size of 1.

  • NewCacheThreadPool: newCacheThreadPool, an unlimited thread pool that creates a thread to execute when a task is submitted.

If the default thread pools aren’t enough for your needs, try custom thread pools. Custom thread pools inherit from ThreadPoolExecutor.

Java collections are one of the most commonly used types of Java, and you should have the entire framework of Java collections memorized in your head:

Collection:

(1) List:

  • LinkedList
  • ArrayList
  • Vector

(2) Set

  • HashSet
  • TreeSet

Map:

  • HashMap
  • TreeMap
  • HashTable

We need to know the characteristics of each container and how they can be expanded (this is important). Choose the appropriate container based on our data size, specific scenario, and business logic.

7. Java memory model

The Java memory model is very important because it relates to the performance of our program. We need to know how memory is allocated, and to which area member variables, static variables, local variables, objects, etc are allocated:

  • Stack memory
  • Heap memory

Garbage collection mechanism:

When it comes to memory, we need to be aware of Java’s garbage collection mechanism, although Java does not require us to allocate and free memory as c++ does. But we still need to know its recycling mechanism, generational recycling:

  • Young generation: 1 Eden district and 2 Survivor districts
  • Old generation
  • The permanent generation

Generational collection is divided into three generations. The timing and frequency of garbage collection in each generation are different, so the recycling algorithm used is also different.

In general, the recycling frequency of the young generation is high, and the life cycle of the object is short. After a certain number of recycling cycles, if the object of the young generation is still alive, it will be moved to the old generation. The recycling of the old generation is time-consuming, the recycling frequency is low, and the recycling cost is high.

Summary of Java Basics: This is a brief summary of Java basics. These are some of the most common or frequently needed concerns in Android development. If you want to learn the basics of Java in a systematic way, you are recommended to read the classic book Thinking in Java.

Like building a house, to build a great building, you must first lay solid foundations. Also, as an Android developer, if you want to go further, you need to learn the basics of Android.

Android four components are the root of Android, from the time we learn Android, we first know them:

  • Activity
  • Service
  • BroadcastReceiver
  • ContentProvider

Activity:

We can see an Activity interface in our APP. When it comes to activities, we need to know:

  • 1. The Activity lifecycle

  • Standard SingleTask SingleTop SingleInstance

    Keep in mind the differences between these boot options.

  • 3. How to transmit data between activities?

  • 4. What are the changes in the Activity life cycle?
  • 5. What is the difference between Intent and implicit Intent?

Service:

Service is another component we use a lot. We need to know about Service:

  • The Service life cycle
  • There are two ways to start a Service:

    1, startService

    2, bindService

    The lifecycle approaches taken by the two startup modes are different

  • Service vs IntentService: Service and IntentService are used in different scenarios. Look it up!

BroadcastReceiver:

There are two ways to register a broadcast: register in the Manifest file and register in the code. The registered broadcast in the code is generally a local broadcast. It is best to register and unRegister in pairs.

Global broadcast can be accessed across applications, has security implications and is inefficient, so a more secure and efficient alternative has emerged: LocalBroadcastReceiver, which is very simple to use. I give you bonus points for seeing LocalBroadcastReceiver instead of BroadCastReceiver in your code.

ContentProvider ContentProvider may not be used very much, but can be used to share data, provide data sources, and master the ability to write, add, delete, change, and check.

To recap: The four major components need to be declared in a manifest file.

2. Common Android layouts

  • 1, FrameLayout FrameLayout
  • 2, LinearLayout
  • 3. RelativeLayout
  • ConstraintLayout, Google’s new ConstraintLayout

3 . Android Studio

Android Studio is a common tool for Android development. Proficiency in operating and using the shortcut keys and some plug-ins above will greatly help our development efficiency.

Android Studio has many useful plug-ins that you can install according to your needs, such as:

  • GsonFormat
  • Parcelable serialization
  • Translation plug-in: for English is not very good very helpful.

In addition to some easy to use plug-ins, but also according to their own habits to set some shortcut keys, in short, to good work, must first sharpen its device. To improve the development effect, first configure our development tools.

4 . Fragment

  • 1. Fragment life cycle
  • 2. Communication modes between fragments
  • 3. Communication mode between Fragment and Activity
  • Fragment + ViewPager
  • Fragment +TabLayout TAB

Android has its own database Sqlite, about the database, we should be familiar with:

  • 1. Create databases and tables
  • 2. Data addition, deletion, modification and check.
  • 3, database upgrade: this is particularly important, because the database upgrade is often accompanied by data upgrade, can not upgrade the user data in front of the lost.
  • GreenDao: If you find it too much trouble to do this yourself, you can choose to use some of your third-party libraries, such as GreenDao, which already encapsulate all of these operations for you and can be used with simple configuration. Of course, there are plenty of similar libraries on Github, and you can choose from them according to your needs.

    6. Common controls Basic controls

  • 1,RecyclerView & ListView

  • 2,ViewPager
  • 3,TextView
  • 4,ImageView
  • 5, the Button
  • 6, the Checkbox
  • 7,RadioButton

All complex interfaces are made up of these simple basic controls, so you need to understand their various properties.

### ### ### ### ### ### #

Some basic views and controls are listed above, but these basic controls sometimes do not meet our needs, this time we need to customize the View.

Custom View:

There are three ways to customize a view:

  • 1. Combine basic controls
  • 2. Inherit the base controls and make changes accordingly.
  • 3, Inherit View or ViewGroup:

    This method is also the one we often use. This method is relatively free and has a high definition system. The following methods need to be implemented: (1) onMeasure() (2) onLayout() (3) onDraw()

Execute onMeasure()->onLayout() -> onDraw().

View event distribution mechanism: When we customize the View, we need to respond to the user’s various events, this time we need to understand the View event distribution mechanism.

For the event distribution mechanism, take a look at the classic graph (U-shaped graph) :

When all of these methods call super, the entire event goes through the U-shaped graph. The event distribution mechanism is a bit more difficult to understand, please refer to the resources for more details.

Several architectures of apps

  • MVC
  • MVP
  • MVVM

There are three common architectures, which can be selected according to their own business needs. Each architecture has its own advantages and disadvantages. In addition, I think multiple architectures can coexist in an APP, such as MVC and MVP. A very simple presentation interface, it doesn’t have to have a P layer for it, but becomes complicated.

Android animation

(1) 5 basic animations in Android

  • Translation of animation
  • Zoom animation
  • Rotating animation
  • Alpha animation
  • The frame of animation

(2) Attribute animation

Tween animation is very simple, but its scene usage is limited, it can only animate a View. Sometimes, we need more precise control, we need to animate a property, and that’s where the property animation comes in. Several related classes of property animation:

  • ObjectAnimator
  • ValueAnimator
  • AnimatorSet

Attribute animation is used more widely, attribute animation + custom View configuration Path and Bezier curve can make a lot of complex beautiful effects.

(3) Vector animation

  • svg
  • VectorDrawable
  • AnimatedVectorDrawable

VectorDrawable and AnimatedVectorDrawable Can be used to animate vectors by importing an Svg file into a path. But it needs to be above Android5.0.

4. Material Design series

Since Android 5.0, Google has released the Material Design specification, and the Android Support package also includes various controls that conform to the Material Design specification:

  • 1, the use of the Toolbar
  • 2, AppbarLayout + CollapsingToolbarLayout
  • 3, Behavior related:

    (1), BottomSheetBehavior (2), BottomSheetDialog (3),SwipeDismissBehavior (4), custom Behavior

  • 4, TextInputLayout + TextInputEditText
  • 5, TabLayout
  • 6, BottomNavigationView
  • 7, CardView shadow card
  • Snackbar, FloatActionButton

With these controls, you can create many effects and animations that conform to material Design specifications.

More about the Material the use of the Design, please have a look at my blog series: www.jianshu.com/u/35167a70a…

5. Android Multimedia

Multimedia is also an important and difficult part of Android development, as it is designed for camera, video, and audio related development.

Camera Development:

   1, use your own camera APP to take photos2, system album to select photos3, system camera or album capture photo cropping4, using camera API to develop camera: (1), the Android5.0(API21) forCamera API 
        (2), Android 5.0 above using Camera2 API 5, custom album development 6, custom cropping interfaceCopy the code

Android Video Development:

(1) Video playback MediaPlayer VideoView (2) Video codecCopy the code

Audio development:

AudioPlayer Music playerCopy the code

The threshold of audio and video development is relatively high, but it is also a popular field. If you have a thorough understanding of this area, you will have a great advantage. Now live broadcasting is so popular, there is a relatively large demand for this area.

Git version control is also commonly used by us, familiar with various Git commands. Android Studio is already integrated with code submission, code pulling, and historical version viewing, but it is recommended that you use the command line to familiarize yourself with Git commands.

7. Android permission adaptation

Android 6.0 or above permission adaptation.

8 . Gradle

  • Customize Gradle plug-ins
  • Gradle is packaged in multiple channels

So that’s a little bit about Android.

Learn about open source libraries

Github is an absolute treasure for us programmers. There are all kinds of open source libraries on Github, but you can’t think of anything you can’t find. Companies also have a variety of open source solutions.

Here are some of the more popular frameworks:

Image loading frame:

  • Universal-Imageloader
  • Picasso
  • Glide
  • Frecssco

Network related framework:

  • Retrofit
  • Okhttp
  • Volley

RxJava :

  • RxJava
  • RxAndroid

Database:

  • GreenDao
  • OrmLite
  • Realm

The above are some of the most popular frameworks at the moment. RxJava in particular, when you see the variety of RXxxx on Github, you can see how popular RxJava is. (Adding an Rx feels like forcing a higher level).

If you feel that the Java foundation, Android foundation these things are almost learned, the whole understand. So it’s time to learn these frameworks, how do we learn them? Not only to learn how to use, we can go to learn the source code, learn their entire framework design ideas, code specifications. For some functions you can write an identical one. For example: cache, image loading framework are multi-level cache, we can look at the implementation of each framework cache is different, what are the advantages and disadvantages, and finally copy one, make it our own.

Learn to build a wheel

When we have a certain amount of accumulation, try to build the wheel. It can be a simple View, a cool animation effect, a common component extraction. Encapsulate these common functions into a library. When we implement similar features in the future, we can avoid reinventing the brick.

If conditions permit, we can open source it on Github, so that others can learn and use it. Open source is a good thing for everyone. For others: borrow ideas, or use them directly in a project. As for myself, bensen is also an opportunity to improve myself when users find bugs and give us feedback to fix bugs and upgrade the version. At the same time, they can communicate with each other and learn from experience.

If you haven’t started writing an open source library yet, try writing one now.

Collect your own library of utility classes

You can look at your project right now. Is there an Utils package in it? Don’t look at it, there must be, there are all kinds of tool classes that you use.

Maybe you have the same feeling as me, some common operations such as reading and writing files, Bitmap conversion, date formatting and so on. When we use it, it’s hard to write it all at once. We might remember a project we used in the past and go back to that project, or maybe go to Google and copy a piece of code.

These are common functions, and the code is relatively fixed, so we can collect the utility classes that we normally use into a single class library. Then sort them into categories:

  • File operation correlationFileUtils
  • The Bitmap operation is relatedBitmapUtils
  • Date formatting correlationDateUtils

The above are just three examples, all of which can be collected.

When you have been working for three or five years, and you come back and look at the library, it might be different.

Learn to think and summarize

When we learn a function or solve a problem, we can sort out and summarize the whole process. If we do not think and summarize after learning or solving a problem, we may forget all of it after a period of time. A good memory is better than a bad one. Tidy up, take a note or write a blog post. There are many benefits to doing this:

1. It is helpful to deepen our memory.

2, the context is clear, which helps us to have a deeper understanding.

3. Even if you forget it later, you can look at your notes or blog again and remember it again.

4. It can also help others avoid the same problems.

When you’re done with a project, give yourself some time to comb through and summarize. If you haven’t already, start now. In a word, it is important to form your own knowledge system.

Eight, the last

In this article, I’ve combed through some of the things that Android developers learn as they progress, and some of my personal advice. About Java foundation, Android foundation, Android advanced, just made the knowledge point comb, no solution, point to the end. Want to study these knowledge points in detail still need oneself to read a book, see blog, check data to wait. Of course, the knowledge points listed in this article are not complete, to more systematic learning, you can buy a book to learn.

Finally, all the knowledge points in this article are ready to be organized into a mind map, which will be published on the public account. Please pay attention and subscribe.

My level is limited, personal ignorance, if there is any mistake, welcome to point out.

More Android dry goods articles, pay attention to the public number [Android technology grocery store]