[英]How to create dynamic URLs using Build Flavors in Android (Android Studio)
How to create dynamic URLs using Build Flavors in Android (Android Studio) I have more than 15 URLs for each environment in my app, and in total we have 5 environments, how do I use these URLs from a common class, based on the Activated build variant.如何在 Android (Android Studio) 中使用 Build Flavors 创建动态 URL 我的应用程序中的每个环境都有超过 15 个 URL,总共有 5 个环境,我如何使用来自常见 class 的这些 URL,基于 Activated构建变体。
Create an option in you app for switching environments.在您的应用程序中创建一个用于切换环境的选项。
Hope these steps might help you.希望这些步骤可能对您有所帮助。
Steps ->步骤->
Inside your manifest for each activity that will handle the dynamic link add a specific intent-filter.在将处理动态链接的每个活动的清单中添加特定的意图过滤器。
<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>
where the pathPrefix comes from a flavor specific resource string.其中 pathPrefix 来自风味特定的资源字符串。
<resources>
<string name="uri_myoperation_path_prefix" translatable="false">/<FLAVOR>/myoperation</string>
</resources>
The dynamic link has common scheme and host but a specific path section for each flavor.动态链接具有共同的方案和主机,但每种风味都有一个特定的路径部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.