[Alibaba arouter] simple and easy-to-use Android page routing framework

When developing an app, you will always encounter various needs and businesses. At this time, you can get twice the result with half the effort by choosing a simple and easy-to-use wheel

preface

In the above code, the most common and commonly used function in Android development is page Jump. We often need to face the need to jump from the browser or other apps to the pages in our own apps. However, even simple page Jump will encounter some problems over time:

Another wheel

In order to solve the above problems, we need a routing component that is decoupled, simple, multi-functional, highly customizable and supports interception logic: we chose Alibaba's arouter.

1、 Function introduction

2、 Unsupported features

3、 Typical application scenarios

4、 Basic functions

Add dependencies and configurations

apply plugin: 'com.neenbedankt.android-apt'

adding annotations

Initialize SDK

Initiate routing operation

Add obfuscation rule (if Proguard is used)

5、 Advanced usage

Jump through URL

Use arouter to assist in resolving parameter types

Enable automatic injection of arouter parameters (experimental function, not recommended, protection strategy under development)

Declare interceptor (intercept jump process and do things face to face)

Process jump results

Customize global degradation policy

Declare more information for the target page

Using arouter management services (I) exposing services

Using arouter to manage services (II) discover services

1. Service can be obtained through two APIs: byname and bytype

2. Note: it is recommended to use byname to obtain the service. Bytype is convenient to write, but if there are multiple implementations, the SDK does not guarantee to obtain the implementation you want

Using arouter management service (III) managing dependencies

You can wrap your business logic or SDK through arouter service and initialize your SDK in the init method of service. Different SDKs are called by arouter service. Each service will be initialized when used for the first time, that is, call the init method.

In this way, we can bid farewell to the sorting of various messy dependencies. As long as we can call this service, the SDK contained in this service has been initialized, and we don't need to care about the initialization order of each SDK at all.

6、 More features

Other settings in initialization

Detailed API description

appendix

Arouter GitHub link

Latest version

Gradle dependency

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