Preface For most junior students, this summer vacation is their first one in their lives. For IT students, they will face the autumn recruitment of major IT companies after school starts, and many will become Android interns starting from scratch. On the road to Android beginners, every Android intern will encounter various bottlenecks. To overcome the bottleneck, you must overcome your prejudice against all bottlenecks, and turn the behavior of avoiding bottlenecks into the process of enjoying the pleasure brought by bottlenecks. You should know that one of the important reasons why Heineken is much more expensive than domestic beer is the bottleneck of Heineken: if you buy a bottle of Heineken in a glass bottle now, hold the bottleneck with your hand, press the star with your thumb, and then use the action you are most familiar with to rub the bottleneck, you will like this feeling. Android layout and screen adaptation The first bottleneck that Android beginners encounter is the writing of Android layout. First of all, Android layout is written in XML, and most college students learn web page production in college, they use HTML to draw basic controls, and then use CSS to beautify the page; but Android uses XML to draw the interface, and the style is also written in XML. The most important thing about learning XML is practice makes perfect, and you will become proficient with more practice. In addition, XML and HTML have many similarities, such as the difference between padding and margin is the same. In addition, the Android system is severely fragmented, and different models of mobile phones have different screen sizes and resolutions. To solve this problem, we can make the background texture in .9png format and use content and padding to support the control. If the model to be adapted is too extreme, we can solve this problem with percentage layouts - PercentRelativeLayout and PercentFrameLayout, etc. The life cycle of different components The second bottleneck that Android beginners encounter is the life cycle. Android's life cycle mainly includes three types: Activity life cycle, Fragment life cycle, and Service life cycle. If you don't learn the Activity life cycle well, you can't do the special effects of interface jumps, nor can you do the callback of system Activity (camera, etc.); if you don't learn the Fragment life cycle well, you can't write lazy loading; if you don't learn the Service life cycle well, you can't even run it in the background. When learning the life cycle, remember that "text without pictures is less intuitive, and pictures without text are difficult to understand", and use charts to help memorize. Network request and json parsing Android is an important part of the mobile Internet. Network requests and Json parsing are important parts of Android learning. Many beginners will encounter bottlenecks here. In order to break through this bottleneck, beginners should first choose a suitable framework to solve the problems in internship work as soon as possible. Common network request frameworks include Volley and OKHttp; common json parsing frameworks include Gson and Jackson. If your job search target is Alibaba Group, learning FastJson can help you; in addition, there is Retrofit that integrates network request and json parsing. When an intern first enters a company, he should remember to use working time to solve problems at work, and use his spare time to explore knowledge and improve his ability. After get off work, he should learn the source code and implementation principles of the above frameworks. For example, Android network requests must be performed in child threads, otherwise it will cause NetworkOnMainThreadException; current network requests are based on HttpURLConnection, and any information about HttpClient is outdated; he should also understand the principles of Handler, ThreadPool, AsyncTask, etc.; knowledge of json parsing, including the difference between JSONObject and JSONArray, Java generic mechanism, Java reflection mechanism, etc. Image loading and memory optimization Android phones are generally much cheaper than iPhones, so Android systems are more likely to encounter OutOfMemoryError (OOM) than iOS systems, which is also one of the common learning bottlenecks for beginners. OOM is most common in images, followed by maps and videos embedded in the layout, which are also one of the main culprits of OOM. To solve the OOM problem of loading pictures, you should first choose frameworks such as Picasso, Glide, Fresco, etc. to solve the problem at work as soon as possible, and then use personal time to learn the Android cache mechanism - LruCache and DiskLruCache; OOM of maps and videos should clear controls and stop services when the interface is recycled; other OOMs should be solved with weak references and soft references. RecyclerView The most commonly used and most complex control in Android is RecyclerView (ListView in 2014 and earlier), because sliding conflicts, data modification in the list and other issues will be reflected in RecyclerView. In order to overcome these bottlenecks, it is necessary to understand the working principle of RecyclerView.Adapter (including the previous BaseAdapter), the working principle of ViewHolder, and the event distribution mechanism of ViewGroup. These contents cannot be fully mastered without great effort. After overcoming the above bottlenecks, it is estimated that the interns will graduate and become full-time employees. There are new bottlenecks on the road to advancement. New bottlenecks have new ways to play: this way of playing requires two hands to operate. If you use your other hand to hold the open bottle mouth and pull the bottle neck, you can pull and shake it hard, and suddenly release the hand holding the bottle mouth when you are high. Custom Controls Android's built-in controls cannot meet the needs of complex interface controls, so drawing custom controls is also a necessary skill for Android engineers. Drawing custom controls requires mastering the rewriting of several common View methods, such as onDraw(), onMeasure(), onLayout(), etc.; the understanding of the event distribution mechanism should also be more proficient than RecyclerView; in addition, you also need to master the relevant knowledge of Canvas and Animator. Android's Canvas and HTML5's Canvas have many similarities, which can help you break through the learning bottleneck of Canvas. Interprocess Communication Multi-process communication is required between different apps and between different processes of the same app. Multi-process communication is very necessary in situations that take up a lot of resources, such as video playback. Beginners of inter-process communication will be confused by AIDL when they search "multi-process" on Baidu. In fact, if you just try the Messenger framework, all the problems of inter-process communication will be solved. Android performance comprehensive optimization and crash analysis The biggest bottleneck that Android beginners will encounter is the overall optimization of Android performance. The Android memory optimization mentioned above is the most important part of Android performance optimization, but it is only a small part. Android performance optimization also includes installation package size optimization, GUI drawing optimization, power and traffic optimization, etc. In terms of GUI, you can use ViewStub and remove other unnecessary backgrounds to avoid OverDraw; the size of the installation package can be optimized by compressing images, removing duplicate and useless dependencies, etc.; power and traffic can be optimized by replacing polling with push, and downloading long data streams in GZIP file format. In terms of mobile application performance, crashes have the most serious impact. Crashes refer to the forced closure of a large number of ongoing user operations during the running of an App. Crashes can cause key business interruptions, poor product reputation, and user loss. Crashes can be captured with UncaughtExceptionHandler, or analyzed using services such as UMeng and Bugly. Please note: If you plan to switch to Alibaba, use UMeng, and if you want to switch to Tencent, use Bugly. After breaking through all the above bottlenecks, the technical level of Android programmers can reach the level of being able to stand on their own feet. Programmers who have thrown off the hat of beginners will find that the top of their heads is no longer a bottleneck, but a ceiling from technology to management. |
<<: A Brief Discussion on iOS Crash (Part 1)
>>: Android advanced obfuscation and code protection technology
Web-based APP is mainly based on the URL Scheme m...
Events have become one of the most effective ways...
Dairy products counter in supermarket There are s...
The living room is one of the places where family...
As netizens' reading habits become increasing...
A few days ago A shocking video of the constructi...
The editor has received a small request for inter...
What will the iPhone 6 UI look like after it becom...
At 20:09 on December 4, the return capsule of the...
Recently I saw a growth-related topic on Zhihu, w...
A year ago, when I first joined a unicorn company ...
Jinzhai Dabie Mountain Red Education Base trainin...
The desert cat has obvious tufts of hair on the e...
In 2016, China's Internet and venture capital...