Android interview questions experience articles

Preface

Autumn recruits are coming soon, Ji Meng will prepare a set of Android primary interview questions before the end of the National Day holiday. I hope it will be helpful to everyone.


Tip: The following is the content of this article

experience

1. What frameworks and platforms have been used in development

1. EventBus (event processing)
2.xUtils (network, picture, ORM)
3.JPush (Push Platform)
4. Youmi (Youmi), Youlianghui, Pangolin (advertising platform)
5.Youmeng (Statistics Platform)
6. Baidu Map
7. bmob (server platform, SMS verification, email verification, third-party payment)
8.Alibaba Cloud OSS (cloud storage)
9. ShareSDK (sharing platform, third-party login)
10. Gson (parse json data frame)
11. zxing (Scanning the QR code)
12. imageLoader, Fresco, Glide, Picasso (picture processing framework)


2. The principle of three-level cache:

  • 1. Load from the cache.

  • 2. Load from a local file (database, SD)

  • 3. Load from the network.


3. How to clear the cache?

(1) Clear the memory cache.

(2) Database, SD.


4. The benefits of push:

Timely initiative, targeted, convenient and efficient.


5. Why should the data be transmitted in json format?

Legibility, high efficiency


6. Project process

Project establishment: determine the project, person in charge, development cycle, cost, manpower, and material resources.
Requirement: documents, prototype drawings.
Development: coding.
Test: testers
. Online: product department.
Maintenance: fix new bugs.
Upgrade: revise and add new features


7. Custom view keywords

Basic: Coordinate system, angle radian, color
Advanced: Canvas path Bezier curve matrix event distribution processing measurement...


8. The realization idea of ​​custom view

Combination controls, self-drawn controls, inherited controls


9.Retrofit use

1. Use an interface as the api interface for http requests in retrofit

public interface NetApi {
    
    
    @GET("repos/{owner}/{repo}/contributors")
    Call<ResponseBody> contributorsBySimpleGetCall(@Path("owner") String owner, @Path("repo") String repo);
}

2. Create a Retrofit instance

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://api.github.com/")
        .build();

3. Call the api interface

NetApi repo = retrofit.create(NetApi.class);

//第三步:调用网络请求的接口获取网络请求
retrofit2.Call<ResponseBody> call = repo.contributorsBySimpleGetCall("username", "path");
call.enqueue(new Callback<ResponseBody>() {
    
     //进行异步请求
    @Override
    public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
    
    
        //进行异步操作
    }

    @Override
    public void onFailure(Call<ResponseBody> call, Throwable t) {
    
    
        //执行错误回调方法
    }
});

10. Advantages of componentization

  • Componentization separates common modules and manages them in a unified manner to improve reuse. The page is split into smaller granular components. The internal components include UI implementation, and can also include data and logic layers.
  • Each component can be compiled independently, speed up the compilation, and package independently.
  • Modifications within each project will not affect other projects.
  • The business library project can be quickly split and integrated into other apps.
  • Business modules with frequent iterations adopt the component approach, business line R&D can not interfere with each other, improve collaboration efficiency, control product quality, and strengthen stability.
  • Parallel development, team members only pay attention to their own development of small modules, reduce coupling, easy maintenance and so on.

11. The advantages of plug-in

  • In a large project, in order to have a clear division of labor, different teams are often responsible for different plug-in apps, so that the division of labor is more clear. Each module is packaged into different plug-in APKs, and different modules can be compiled separately, which improves development efficiency.
  • Solve the problem that the number of methods mentioned above exceeds the limit. The online BUG can be solved by launching a new plug-in to achieve the effect of "hot fix".
  • Reduce the size of the host APK.

Apps developed by plug-ins cannot be launched on Google Play (no overseas markets).


12. Packing principle

  1. Use the AAPT tool to package resource files (including AndroidManifest.xml, layout files, various xml resources, etc.) to generate R.java files.
  2. Process AIDL files through AIDL tools to generate corresponding Java files.
  3. Compile the project source code with Javac tool to generate Class file.
  4. Convert all Class files into DEX files through the DX tool. This process mainly completes the conversion of Java bytecode into Dalvik bytecode, compressing the constant pool, and removing redundant information.
  5. Use ApkBuilder tool to package resource files and DEX files to generate APK files.
  6. Use KeyStore to sign the generated APK file.
  7. If it is the official version of the APK, the ZipAlign tool will be used for alignment. The alignment process is to offset the starting distance of all resource file example files in the APK file by an integer multiple of 4 bytes, so that the APK is accessed through memory mapping. The file speed will be faster.

13. Installation process

  1. Copy the APK to the /data/app directory, unzip and scan the installation package.
  2. The resource manager parses the resource files in the APK.
  3. Parse the AndroidManifest file and create a corresponding application data directory under the /data/data/ directory.
  4. Then optimize the dex file and save it in the dalvik-cache directory.
  5. Register the four major component information parsed by the AndroidManifest file in the PackageManagerService.
  6. After the installation is complete, send a broadcast.

14. How to prevent decompilation (improve the difficulty of decompilation)

Since the apk is loaded by the Android virtual machine, it has certain specifications, and Dalvik cannot recognize the apk after encrypting the apk.
It is impossible to avoid completely, someone can always crack your code. However, there are several ways to increase the difficulty of decompiling code.
1 The key code uses jni to call the local code, written in C or C++, so it is relatively difficult to decompile.
2 Obfuscate java code
3. Use third-party reinforcement


15.v1, v2 signature result

  • v1: Only the uncompressed file content is verified in v1, so many modifications can be made after the APK is signed-the file can be moved or even recompressed. That is, the signed file can be processed
  • v2: The v2 signature verifies all the bytes in the archive, not individual ZIP entries. If you have any custom tasks during the build process, including tampering or processing APK files, please make sure to disable them, otherwise you may make v2 signatures Invalid, thus making your APKs incompatible with Android
    7.0 and above.

16. What are symmetric encryption and asymmetric encryption in the way Android interacts with the server?

Symmetric encryption means that both encryption and decryption of data use the same key. The algorithm in this area is DES.

Asymmetric encryption, encryption and decryption use different keys. Before sending data, you must first agree with the server to generate a public key and a private key. Data encrypted with the public key can be decrypted with the private key, and vice versa. The algorithm in this area is RSA. Both ssh and ssl are typical asymmetric encryption.


17. Process keep-alive program

1. Use system broadcast to pull live (obvious defects)
2. Use system Service mechanism to pull live
3. Use Native process to pull live (a bit difficult after
Android 5.0 ) 4. Use JobScheduler mechanism to pull live
5. Use account synchronization mechanism to pull live


18.Binder mechanism advantages

In Linux, the communication mechanism has 1. pipe, file sharing 3. socket 4. semaphore
Advantages:

  • 1. Performance: need to copy once (second only to shared memory)

  • 2. Features: Based on the cs architecture, high ease of use (just configure aidl)

  • 3. Security: UID is assigned to each APP, and real name and anonymity are supported at the same time (traditionally, the upper layer protocol needs to be relied on, and the access point is open and insecure)


19. The difference between URI and URL

URI: Uniform Resource Identifier, used to uniquely identify a resource.
Three components:
1. The naming mechanism for accessing the resource.
2. The host name for storing the resource.
3. The name of the resource itself, represented by a path, with emphasis on the resource

URL: Uniform Resource Locator, it is a specific URI, that is, URL can be used to identify a resource, and it also specifies how to locate the resource.
Three components
1. Protocol
2. Host IP address where the resource is stored
3. Specific address of the host resource


20.TLS/SSL handshake

The principle of cryptography (algorithm, secret key)
symmetric encryption, asymmetric encryption. Asymmetric encryption used by SSL
Symmetric encryption: The secret key used for encrypting data is the same as the
secret key used for decryption. Asymmetric secret key: private secret key, and public secret key.
Digital certificate
is one of the identity information of communicating parties in Internet communication. Serial number (a file)
handshake process
1. The client initiates a request 2. The server responds 3. The client verifies the certificate 4. Generates a secret key 5. The client generates data


About sorting out

When everything is sorted, it will be sorted into pdf format for easy reading. The file is obtained as shown below (after October 8)!


Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42761395/article/details/108909161