Explain in detail the use of URL schema for Android business componentization

preface:

Recently, the company's business has developed rapidly, and a single project is no longer suitable for the company's development needs, so it began to promote the Componentization of the company's app business. I'm honored to take the lead in doing this. After research, the componentized communication scheme is realized through URL schema. Therefore, I think it's still in the pre research stage. It's necessary to first understand the URL schema and see how it is used? In fact, I came into contact with URL schema when I was doing hybrid programming before. Generally speaking, it is not strange. Let's review and summarize it today.

What is a URL schema?

Scheme in Android is an intra page Jump protocol and a very good implementation mechanism. It is very convenient to jump to each page in the app by defining its own scheme protocol; Through the scheme protocol, the server can tell the app to jump to that page, jump to the page through the notification bar message, jump to the page through the H5 page, etc.

URL schema application scenario:

The client application can register a URL scheme with the operating system, which is used to start the application from the browser or other applications. Through the specified URL field, the application can directly open some specific pages after being called, such as product details page, activity details page, etc. You can also perform some specified actions, such as completing payment. You can also directly call and display a page in the app through HTML pages in the application. To sum up, the usage scenarios of URL schema can be roughly divided into the following categories:

• the server sends the jump path, and the client jumps to the corresponding page according to the jump path sent by the server • click the anchor on the H5 page and jump to the specific page according to the specific jump path of the anchor • the app receives the push notification bar message sent by the server, and jumps to the relevant page according to the click jump path of the message • the app jumps to another app designated page according to the URL

URL schema protocol format:

Let's start with a complete URL schema protocol format:

xl://goods:8888/goodsDetail? Goodsid = 10011002 includes all the above paths: schema, host, port, path and query. Basically, this is the path used in daily life.

• XL represents the protocol name of the schema • goods represents which address domain the schema works on • goodsdetail represents the page specified by the schema • goodsid represents the passed parameters • 8888 represents the port number of the path

How to use URL schema:

1.) at Android manifest Add < intent filter / > to < activity / > tag in XML and set schema

2.) get the parameters of schema jump

3.) calling method

On the web page

Native call

4.) how to judge whether a schema is valid

Summary:

There are so many basic uses of schema. Other uses will be summarized when they are used in the future.

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
分享
二维码
< <上一篇
下一篇>>