Activity 間跳轉核心 API:
// 顯式跳轉
Intent intent = new Intent(CurrentActivity.this, TargetActivity.class);
intent.putExtra("key", "value"); // 攜帶資料
startActivity(intent);
// 隱式跳轉 (啟動其他 App 組件)
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com"));
startActivity(intent);
com.app
├─ ui
│ ├─ login (LoginActivity, LoginFragment, LoginViewModel)
│ ├─ main (MainActivity, HomeFragment, ...)
│ └─ profile
├─ data (Repository, RoomDao, RetrofitService)
├─ domain (UseCase, Entity)
└─ di (Hilt/Koin Module)
Navigator 單例或擴充函數,集中管理跳轉邏輯:
object Navigator {
fun startLogin(context: Context) {
context.startActivity(Intent(context, LoginActivity::class.java))
}
fun startMain(context: Context, userId: String) {
Intent(context, MainActivity::class.java).apply {
putExtra("USER_ID", userId)
}.also(context::startActivity)
}
}
Dynamic Feature Module (Play Feature Delivery) 按需下載功能模組,跳轉時檢查模組是否安裝 (SplitInstallManager)。「跳轉邏輯集中化、參數命名規範化、模組邊界清晰化。」