【发布时间】:2013-07-11 20:58:42
【问题描述】:
我在 Google Play、Amazon、Samsung Apps 中有应用程序,我计划上传到其他商店。 我不希望为每个商店编译单独的版本。 如果同一个应用提交到不同的商店,有没有办法检测哪个商店安装了应用?
【问题讨论】:
标签: android google-play samsung-mobile amazon-appstore
我在 Google Play、Amazon、Samsung Apps 中有应用程序,我计划上传到其他商店。 我不希望为每个商店编译单独的版本。 如果同一个应用提交到不同的商店,有没有办法检测哪个商店安装了应用?
【问题讨论】:
标签: android google-play samsung-mobile amazon-appstore
您必须为每个额外的商店扩展它,但这应该可以帮助您开始
if (context.getPackageManager().getInstallerPackageName(context.getPackageName()).equals("com.android.vending")
{
//do google things
}
else if (context.getPackageManager().getInstallerPackageName(context.getPackageName()).equals("com.amazon.venezia")
{
//do amazon things
}
【讨论】:
我在 MainActivity 中检测到这样的安装程序:
//is installed via amazon, google?
String installerId = null;
try {
installerId = this.getPackageManager().getInstallerPackageName(this.getPackageName());
} catch (Exception e) {
//just in case...
}
if ("com.amazon.venezia".equals(installerId)) {
// amazon
} else if ("com.android.vending".equals(installerId)) {
// google
} else {
// others & unknown ones
}
我已经在我的上一个应用程序中对此进行了测试,它通过了在 googe play、amazon store 和 slideme.org store 中的应用程序提交
更新:看起来有时安装程序包名称 com.google.android.feedback 似乎也与谷歌商店有关,虽然我见过在我的测试应用程序的谷歌分析中,com.android.vending 的频率要高得多。所以如果你想让这个更精确,你也应该处理这个安装程序包。 另请注意,某些市场(如 slideme.org)似乎根本没有设置包安装程序 ID。
【讨论】:
除非您进行单独的构建,否则不会。但是通过一个好的 maven setup/ant 脚本,你可以轻松地自动化这个过程。
【讨论】: