If you want me to re-design an Android App, androidapp

Source: Internet
Author: User

If you want me to re-design an Android App, androidapp

Reprinted please indicate the source:

This article from aspook blog: http://blog.csdn.net/ahence/article/details/47154419

Selection of development tools

I will use Android Studio as the Android development tool officially designated by Google. It is a stable version of 1.2.2 and the preview version of 1.3 has been released. The advantages of Android Studio do not need to be discussed. Most open-source Android libraries on GitHub have been migrated to Android Studio. When jar files are not provided, android Studio allows you to easily integrate open-source libraries. Most importantly, Google has announced that it will stop all Support for Eclipse Android development Tools by the end of the year (Google Ends Support for Android Eclipse Tools). Therefore, please move to Android Studio as soon as possible.

App Design Style

For a developer, it seems that there is no decision, and the final decision is in the hands of the product department. In this case, I will try my best to persuade the product department to Design the App into a Material Design style. This is a lot of tears. As an Android developer, I am developing iOS apps all day. I believe many companies are doing this. In order to save costs and time, android and iOS share a set of UIS. The most common example is to put a return button in the upper left corner of every page TitleBar In the Android App. This is required in iOS, but Android has a return key, this design is totally redundant for Android. We sincerely hope that product designers will respect the style and usage habits of each operating system and do not design nondescribable products. Material Design provides such a specification. Since the publication of the MD specification, its elegant Design and fresh style have attracted a large number of designers and developers, today, the MD design is not only on Android (the official library already supports the MD style), but also on CSS, HTML, and JavaScript web page design. Therefore, for the Design style of the App, Material Design cannot be left alone. You may have missed Android Design. Please do not miss Material Design any more.

Related links:

Official Material Design website

Material Design Color Template

MD: A design case website

MD-style Andorid drawer source code: Android-MaterialDesign-NavigationDrawer

An MD-style App source code (for example): Android-MaterialDesign-DBMZ

Supported versions

For the lowest version supported by Android, you can refer to the market share of each version. The most reliable thing is to decide based on the statistics of your App. Currently, our App supports a minimum of 2.2. In my opinion, although 2. there are still some users in Version x, but in fact mobile phone updates are extremely fast. For better user experience and application of updated APIs (many third-party libraries also have version requirements ), the minimum supported version should be improved, which is about 3.0, that is, the API Level is 11.

App Framework Design

I believe everyone understands that with the increase of functional modules, apps are getting bigger and bigger. Without a good architecture design, the code will become bloated and difficult to maintain, the Coupling Degree of each function module is getting higher and higher. Therefore, the App can be modularized and a complete App can be divided into several relatively independent modules, which can reduce the coupling between modules and facilitate reuse.

1. Network Module

Few single-host apps are available. Most of them need to be connected and data is requested from servers. Therefore, network module is essential. There are also many open-source network frameworks on GitHub. I personally think that the open-source framework can be used. At present, I will select okHttp or Volley. Maybe a better network framework will appear in the future. Note that if you use an open-source framework, you must read the source code and be able to control it, so that you will not be helpless when a bug occurs. Of course, you can also write the network module by yourself. At present, our App network module is completely written by yourself. The advantage is that you are familiar with the code you have written and can quickly locate the problem when there is a bug, at the same time, pay attention to handling some details in the networking process, such:

(1) HTTPS support and HTTPS certificate verification (many of the current practices allow all HTTPS certificates by default. In fact, this is not secure and should actually be verified)

(2) supports Wap-based Internet access and mobile, Unicom, and telecom proxy settings

(3) Support for redirection and data compression and transmission

(4) Other noteworthy issues

Writing a network framework by yourself can perfectly process these details, but the time is relatively high. If you use an open-source framework, these details are generally not handled, so we can make some modifications on a third-party framework, which will save a lot of time costs.

2. Image Management Module

Images are also an indispensable element in the App, and images occupy a large amount of memory. Therefore, the image management framework is particularly important. Poor image frameworks may cause memory leaks or even crashes. Of course, you can implement the image framework by yourself (which we do now) to download, decode, cache, and perform other key steps. I personally suggest using some good image libraries, which may be more comprehensive and efficient than managing images by ourselves. I will recommend the following image management libraries:

(1) Some official Google Apps, such as Google photos, use Glide. Do you want to explain more?

(2) Fresco, FaceBook's open-source Library, is extremely powerful and supports WebP, Gif, and JPEG progressive display. The key is its design philosophy on image memory, which greatly reduces the image memory overhead.

(3) Android-Universal-Image-Loader: Before the Image library is displayed, it seems like this is the most popular. It was also used in my personal apps.

(4) Open Source library of Picasso and Square. It is said that Glide was designed with reference to Picasso.

3. Local database module

Maybe your App needs to use a local database. We recommend that you use a popular ORM framework, such as ActiveAndroid or greenDAO. Using a third-party library will greatly facilitate your operations on sqlite, I personally think that we need to pay attention to database upgrades and multi-thread concurrent database operations during use.

4. File Management Module

An App will certainly involve some files, such as configuration files, images, videos, audios, and SharedPreferences files. We can provide a global file management module for file addition, deletion, modification, and query operations. In addition, File compression and file upload and download operations are also required. multi-thread concurrent download and resumable upload are required for downloads.

5. Communication between components and components

For an App, component communication is essential. The communication type can be divided into point-to-point and point-to-point communication. Point-to-point means that only a unique receiver can respond to a message, and point-to-point communication is similar to message broadcast, that is, all registered users can respond to messages. In Android, the message mechanism is usually used, but the message mechanism has a high Coupling Degree. There are also some communication frameworks, such as EventBus and Otto, which can greatly reduce the coupling between components, but cannot implement point-to-point communication perfectly, therefore, we recommend that you use the message and event bus mechanisms in combination.

6. Data Processing Framework

In fact, there should also be a data processing framework. When a data request is sent (by sub-thread) and the data is returned by the Network Module (generally in JSON format), JSON data cannot be directly sent to the View layer for use, the process needs to be parsed into a corresponding Model and cached as needed. Therefore, these processes can be abstracted into a data processing framework. This framework can be considered to accept the data request url and return the data Model to Activity or Fragment. For JSON data parsing, fastjson is recommended, which is fast and stable, and the default value is also complete.

7. Thread Scheduling Module

In fact, there are many operations in Android, such as data request, image download, and cache clearing, which need to be executed in sub-threads. In many cases, a Thread is directly used, this will be messy and difficult to manage when there are too many threads. Therefore, a thread scheduling module can be abstracted to maintain a thread pool. If a thread is needed, the thread scheduling module can fetch the thread to facilitate unified management. Of course, thread operations in third-party libraries cannot be managed by the thread scheduling module, but other operations involving threads should be processed in a unified manner.

8. Business Layer

The business layer is about four main components, Fragment and View. We recommend that you use native components as much as possible and use fewer custom components because native components have the best performance. In addition, we recommend that you use the MVC mode. As long as you design and manage your own logic, MVP, MVVM, and other models all have defects. In short, you should look for a compromise.

9. APK Dynamic Loading Mechanism

As the App grows and its functions expand, many apps have adopted the APK dynamic loading mechanism, which can also be called ins. Because I have not applied it in the actual App, I cannot comment too much. However, I personally think this mechanism is promising and will facilitate App decoupling, function expansion, and local upgrade. For details, refer to a commercial solution: ApkPlug-mobile app modular solution and an open-source APK dynamic loading framework.

10. App security considerations

Android App security issues are rarely valued, but this is indeed a serious problem. Some good apps are often cracked. We recommend that you write some core algorithms. so library, the important logic is placed on the server side, data requests are encrypted, and so on. In addition, to package the APK, you can also use the APK shelling mechanism. In short, such preventive measures will never be too many.

After writing so much in one breath without logic, there may be missing content that will be supplemented in the future. I want to develop at least a good App based on the above principles.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.