Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在应用程序启动时,如何知道一个 android 应用程序来自 Google Play 商店或其他商店,例如亚马逊商店。
虽然它不是万无一失的,但您应该查看以下返回的值:
PackageManager.getInstallerPackageName(nameOfPackage);
有时这会返回一个空/null 字符串,但如果不是,则“com.android.vending”的值表示它是从 Play 商店安装的。并非所有版本的亚马逊商店都设置了这个值,但如果你有一个以“com.amazon”开头的字符串,那么它可能是从亚马逊商店安装的!