Android风味意图活动

Android风味意图活动

问题描述:

如何根据口味创建活动意图?

How to create an intent to an activity depending on the flavor?

层次结构:

main
-ActivityA

flavor(free)
-uses main/ActivityA

flavor(paid)
-uses own paid/ActivityA

那么如何根据当前口味创建一个Intent?

So how to create a Intent depending on the current flavor?

您可以通过其名称获取Activity类.这样,您就不会出现编译错误:

You can get Activity class by it's name. This way you won't get compile errors:

Intent i = new Intent(this, Class.forName("com.xxx.packagename.paid.ActivityA"))