In peacetime development, we often use the page jump function. I've been using intent to jump before.
Intent intent = new Intent(A.this, B.class);intent.putExtra("key","value");startActivity(intent);
最近看到有大牛使用ARouter,专门了解一下,弄个简单入门的demo
A android router middleware that help app navigating to activities and custom services.
- Supports direct parsing of standard URLs for jumps, and automatically injects parameters into the target page
- Support multi-Module engineering use
- Support for adding multiple interceptors, custom intercept order
- Supports dependency injection and can be used as a dependency injection framework alone
- Support Instantrun
- Support for Multidex (Google solutions)
- Mapping relationships by group, multilevel management, on-demand initialization
- Supports user-specified global demotion and local demotion policies
- Pages, interceptors, services, and other components are automatically registered to the framework
- Supports multiple ways to configure transition animations
- Support for Fragment
- Full support for Kotlin and mixed (configuration see other at the end of the article)
Steps to use:
1. Configure Build.gradle:
Add in defaultconfig
Arouter (Android page routing framework)
javacompileoptions {
annotationprocessoroptions {
arguments = [ModuleName:project.getName ()]
}
}
Dependencies
Arouter (Android page routing framework) Https://github.com/alibaba/ARouter
Compile ' com.alibaba:arouter-api:1.2.2 '
Annotationprocessor ' com.alibaba:arouter-compiler:1.1.3 '
2. add annotations to all pages that support routing:
@Route (path=myarouter.mainactivity)
3. Initialize the SDK in application:
4.ARouter initiating page Jump
Demo Link: Https://github.com/HeavenDong/ARouterDemo
Alibaba Open Source 有更详细的使用 : Https://github.com/alibaba/arouter
Android Page Routing Framework--arouter