Android頁面路由架構 —— ARouter

來源:互聯網
上載者:User

標籤:api   and   依賴   攔截器   src   nbsp   1.2   end   tin   

平時開發中,我們經常用到頁面跳轉功能。之前我一直使用Intent過跳轉

Intent intent = new Intent(A.this, B.class);intent.putExtra("key","value");startActivity(intent);

最近看到有大牛使用ARouter,專門瞭解一下,弄個簡單入門的demo

下面的文字粘自Alibaba Open Source

   A android router middleware that help app navigating to activities and custom services.
  1. 支援直接解析標準URL進行跳轉,並自動注入參數到目標頁面中
  2. 支援多模組工程使用
  3. 支援添加多個攔截器,自訂攔截順序
  4. 支援依賴注入,可單獨作為依賴注入架構使用
  5. 支援InstantRun
  6. 支援MultiDex(Google方案)
  7. 映射關係按組分類、多級管理,按需初始化
  8. 支援使用者指定全域降級與局部降級策略
  9. 頁面、攔截器、服務等組件均自動註冊到架構
  10. 支援多種方式配置轉場動畫
  11. 支援擷取Fragment
  12. 完全支援Kotlin以及混編(配置見文末 其他#5)

 

使用步驟:

1. 配置build.gradle:

 defaultConfig中添加

//arouter(Android頁面路由架構)
javaCompileOptions {
annotationProcessorOptions {
arguments = [ moduleName : project.getName() ]
}
}

dependencies中添加
//arouter(Android頁面路由架構)https://github.com/alibaba/ARouter
compile ‘com.alibaba:arouter-api:1.2.2‘
annotationProcessor ‘com.alibaba:arouter-compiler:1.1.3‘


2.所有支援路由的頁面都要添加註解:
@Route(path=MyARouter.MainActivity)

        

3.在application中初始化SDK:

       

  4.ARouter發起頁面跳轉

     

 


Demo連結:https://github.com/HeavenDong/ARouterDemo
alibaba開源有更詳細的使用:https://github.com/alibaba/arouter
 

  

 
 

Android頁面路由架構 —— ARouter

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.