告诉您运行AOSP还是谷歌Android?

时间:2012-09-07 10:30:53

标签: android

我搜索过但找不到这个,虽然主要是知道要搜索什么的挑战,但我确信之前已被问过。

应用如何推断它是在“Google Android”设备上运行,还是在AOSP设备上运行(例如Kindle Fire等)?

3 个答案:

答案 0 :(得分:1)

您可以尝试使用AccountManagergetAccountsByType()枚举设备上的现有帐户,并根据需要传递com.google帐户类型。如果没有此类帐户,则表示它是AOSP设备或用户尚未创建Google帐户。

如果这还不够,您可以使用PackageManager课程并使用getPackageInfo()方法查询某些特定于Google的包。例如,com.android.vending - Google Play应用。

但请注意,这些方法中没有一个可以保证目标设备正在运行AOSP。

答案 1 :(得分:0)

这不是一件容易的事,但大多数应用程序都不需要关心。如果这样做,那么通常意味着您需要一些独特的功能,因此检查某些功能是否存在更为简单,而不是设备上的标签。您也可以检查是否存在某些软件包(例如Google Play),但缺少该软件包并不意味着它会自动消失。

答案 2 :(得分:0)

您可以使用Intent检查是否可以打开市场网址。

关于意图附加内容的文档是here

意图如下:

try {
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("market://details?id=com.example.android"));
  //you can use any package identifier for the check.
  startActivity(intent);
} catch (ActvitiyNotFoundException anfe) {
  //There's no market installed.
  //So you can guess that you're not on a device with Google experience
}

这种方法的缺点是,如果可用,用户将被带到Play商店。

相关问题