Explain the communication mode of Android WebView independent process in detail

Why do you need to put WebView in a separate process

What should WebView independent processes pay attention to

How to declare an independent process

By default, all components of the same application run in the same process. In the manifest, you can set the Android: process attribute of each component (< activity >, < Service >, < receiver >, < provider >) to specify the corresponding process.

Cross process approach

There are two ways to implement it in Android.

One is messenger and the other is Aidl

Messenger

Since messenger is implemented in the form of message queue, handler assistance is required for all receiving and sending.

Server

Customer service end:

AIDL

Step 1: create an. Aidl file

Aidl file:

Server

The customer service end obtains the binding interface

After obtaining the binding interface, you can communicate directly with the server.

The two communication modes are briefly introduced. The later practical applications need to be adjusted according to different services.

Since Aidl is called directly by methods, it is much better than messenger in terms of code extension and reading.

If there is something bad or wrong, I hope you can point it out in time.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>