0

I have an Android application whose name is based on the Application store from where it is installed. For instance

  1. Application Name is A if it is installed form Google Store.
  2. Application Name is B if it is installed from Samsung Store.
  3. 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

  1. 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.

    1. Can we have conditions in Android manifest file ??

    2. Any way via Gradle variables?

Sahil Rally
  • 541
  • 3
  • 15

1 Answers1

1

If you have predefined names for your app you can use <activity-alias>

Please take a look at this reply: https://stackoverflow.com/a/43792801/9796205
It is a little bit old question but it should work.

Francesco Re
  • 836
  • 6
  • 22
  • Thanks for your reference, it worked, although it takes some time after the first launch to change the name of an APP when we enable non-default activity alias. – Sahil Rally Dec 03 '19 at 20:52
  • Yes, unfortunately it is not immediate. Please mark my reply as the correct answer. Thanks – Francesco Re Dec 03 '19 at 21:46