I have an Android application whose name is based on the Application store from where it is installed. For instance
- Application Name is A if it is installed form Google Store.
- Application Name is B if it is installed from Samsung Store.
- Application Name is C if it is installed from Amazon Store.
This is how I can check App store in Android
String pName = BuildConfig.APPLICATION_ID;
PackageManager packageManager = context.getPackageManager();
String installPM = packageManager.getInstallerPackageName(pName);
if ("com.android.vending".equals(installPM)) {
// Installed from the Google Play
return "Google Play";
} else if ("com.amazon.venezia".equals(installPM)) {
// Installed from the Amazon Appstore
return "Amazon Appstore";
}
return "unknown";
}
Note One solution is to have different build variants but I am looking for having a solution that works for single apk.
Few thoughts to solve this
Is there a way in Android where I can select values folder based on custom condition(s). For instance, I can convey to the framework to pick values-samsung folder if it is Samsung App store from where an application is installed.
Can we have conditions in Android manifest file ??
Any way via Gradle variables?