简体   繁体   English

Android Studio:如何获取当前所选产品风味的名称?

[英]Android Studio : How to get name of current selected product flavor?

I have 2 flavors customized. 我有2种口味定制。 Right now, I want to collect different resources from svn for each flavor, and it would be easy to handle if there is a way to get name of current selected product flavor, but I have no idea how to do that.. 现在,我想从svn中为每种口味收集不同的资源,如果有一种方法可以获取当前所选产品口味的名称,那么将很容易处理,但是我不知道该怎么做。

Or Are there any ways to solve this problem? 或有什么方法可以解决这个问题?

get current taskStr and check with your flavor's name is contains <br/> 获取当前taskStr并检查您的风味名称是否包含<br/>

//get current task Str <br/>
String taskStr = getGradle().getStartParameter().getTaskRequests().toString();<br/>

// True if current Flavor is "yourFlavorName"<br/>
taskStr.toLowerCase().contains("yourFlavorName") 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM