Search code examples
androidandroid-intentandroid-activityandroid-productflavors

Android Flavor Intent Activity


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

Hierarchy:

main
-ActivityA

flavor(free)
-uses main/ActivityA

flavor(paid)
-uses own paid/ActivityA

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


Solution

  • 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"))