如何在 Android (Android Studio) 中使用 Build Flavors 創建動態 URL 我的應用程式中的每個環境都有超過 15 個 URL,總共有 5 個環境,我如何使用這些來自通用類的 URL,基于 Activated構建變體。
uj5u.com熱心網友回復:
在您的應用程式中創建一個用于切換環境的選項。
希望這些步驟可以幫到你。
步驟 ->
- 創建一個用于處理所有 URL 的類。
- 顯示基于環境的點擊更改 URL 選項 [隱藏此選項用于生產]
- 根據當前環境顯示帶有 URL 串列的 Dropbox
- 用戶選擇 URL 后,重新啟動應用程式。
uj5u.com熱心網友回復:
在將處理動態鏈接的每個活動的清單中,添加一個特定的意圖過濾器。
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs "https://myapp.com/<FLAVOR>/myoperation” -->
<data
android:scheme="https"
android:host="myapp.com"
android:pathPrefix="@string/uri_myoperation_path_prefix" />
</intent-filter>
其中 pathPrefix 來自特定于風味的資源字串。
<resources>
<string name="uri_myoperation_path_prefix" translatable="false">/<FLAVOR>/myoperation</string>
</resources>
動態鏈接具有共同的方案和主機,但每個風味都有特定的路徑部分,因此鏈接將僅由特定風味的應用程式打開。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/385536.html
標籤:安卓 安卓工作室 android-build-flavors android-variants
