• <small id='hBmsk'></small><noframes id='hBmsk'>

      1. <i id='hBmsk'><tr id='hBmsk'><dt id='hBmsk'><q id='hBmsk'><span id='hBmsk'><b id='hBmsk'><form id='hBmsk'><ins id='hBmsk'></ins><ul id='hBmsk'></ul><sub id='hBmsk'></sub></form><legend id='hBmsk'></legend><bdo id='hBmsk'><pre id='hBmsk'><center id='hBmsk'></center></pre></bdo></b><th id='hBmsk'></th></span></q></dt></tr></i><div id='hBmsk'><tfoot id='hBmsk'></tfoot><dl id='hBmsk'><fieldset id='hBmsk'></fieldset></dl></div>
        <legend id='hBmsk'><style id='hBmsk'><dir id='hBmsk'><q id='hBmsk'></q></dir></style></legend>
          <bdo id='hBmsk'></bdo><ul id='hBmsk'></ul>
      2. <tfoot id='hBmsk'></tfoot>

        无法确定 Android 设备上是否安装了 Google Play 商店

        时间:2023-11-09
          <tbody id='YSbtx'></tbody>

          <small id='YSbtx'></small><noframes id='YSbtx'>

          <i id='YSbtx'><tr id='YSbtx'><dt id='YSbtx'><q id='YSbtx'><span id='YSbtx'><b id='YSbtx'><form id='YSbtx'><ins id='YSbtx'></ins><ul id='YSbtx'></ul><sub id='YSbtx'></sub></form><legend id='YSbtx'></legend><bdo id='YSbtx'><pre id='YSbtx'><center id='YSbtx'></center></pre></bdo></b><th id='YSbtx'></th></span></q></dt></tr></i><div id='YSbtx'><tfoot id='YSbtx'></tfoot><dl id='YSbtx'><fieldset id='YSbtx'></fieldset></dl></div>
          • <bdo id='YSbtx'></bdo><ul id='YSbtx'></ul>
            • <legend id='YSbtx'><style id='YSbtx'><dir id='YSbtx'><q id='YSbtx'></q></dir></style></legend>
              <tfoot id='YSbtx'></tfoot>

                1. 本文介绍了无法确定 Android 设备上是否安装了 Google Play 商店的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是检查设备上已安装软件包的简单问题...在我将操作系统升级到 2.3.5 之前,我可以使用以下代码找到 Market/Play 商店:

                  This was a simple matter of checking the installed packages on the device... before I've upgraded my OS to 2.3.5, I could locate the Market/Play store, using this code:

                  private static final String GooglePlayStorePackageName = "com.google.market";
                  
                  void someMethod() {
                      packageManager = getApplication().getPackageManager();
                      List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
                      for (PackageInfo packageInfo : packages) {
                          if (packageInfo.packageName.equals(GooglePlayStorePackageName)) {
                              googlePlayStoreInstalled = true;
                              break;
                          }
                      }
                  }
                  

                  更新后由于某种原因,我根本找不到表明应用程序已安装的to包名称,虽然它在设备上,我可以访问市场.

                  For some reason after the update, I simply cannot find the to package name to indicate the application is installed, although it is on the device, and I can access the market.

                  包名有变化吗?还是我看错了?

                  Has the package name changed? or perhaps I'm looking at this the wrong way?

                  谢谢,

                  亚当.

                  更新:

                  这是一种检查是否安装了软件包的愚蠢方法……更好的方法是:

                  That was a stupid way to check if a package is installed... a better way is:

                  protected final boolean isPackageInstalled(String packageName) {
                      try {
                          application.getPackageManager().getPackageInfo(packageName, 0);
                      } catch (NameNotFoundException e) {
                          return false;
                      }
                      return true;
                  }
                  

                  推荐答案

                  请注意,这近 5 年的旧代码并不是最优的,Google 不喜欢无缘无故检查所有已安装的软件包.请同时查看其他答案.

                  包名已更改,现在是 com.android.vending

                  The package name has changed, it is now com.android.vending

                  试试:

                  private static final String GooglePlayStorePackageNameOld = "com.google.market";
                  private static final String GooglePlayStorePackageNameNew = "com.android.vending";
                  
                  void someMethod() {
                      PackageManager packageManager = getApplication().getPackageManager();
                      List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
                      for (PackageInfo packageInfo : packages) {
                          if (packageInfo.packageName.equals(GooglePlayStorePackageNameOld) ||
                              packageInfo.packageName.equals(GooglePlayStorePackageNameNew)) {
                              googlePlayStoreInstalled = true;
                              break;
                          }
                      }
                  }
                  

                  这篇关于无法确定 Android 设备上是否安装了 Google Play 商店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:应用内计费不起作用:“未设置 IAB 助手" 下一篇:Android App 与三星 Galaxy S4 不兼容

                  相关文章

                  <small id='FbrEp'></small><noframes id='FbrEp'>

                  <tfoot id='FbrEp'></tfoot><legend id='FbrEp'><style id='FbrEp'><dir id='FbrEp'><q id='FbrEp'></q></dir></style></legend>
                        <bdo id='FbrEp'></bdo><ul id='FbrEp'></ul>
                      <i id='FbrEp'><tr id='FbrEp'><dt id='FbrEp'><q id='FbrEp'><span id='FbrEp'><b id='FbrEp'><form id='FbrEp'><ins id='FbrEp'></ins><ul id='FbrEp'></ul><sub id='FbrEp'></sub></form><legend id='FbrEp'></legend><bdo id='FbrEp'><pre id='FbrEp'><center id='FbrEp'></center></pre></bdo></b><th id='FbrEp'></th></span></q></dt></tr></i><div id='FbrEp'><tfoot id='FbrEp'></tfoot><dl id='FbrEp'><fieldset id='FbrEp'></fieldset></dl></div>