title: Package manager has died while get versionCode in android
body: <p>When I get the version code like:</p>
  
  <pre><code>public static int getVersionCode(Context context) {
      try {
          PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
          return info.versionCode;
      } catch (Exception e) {
          return -1;
      }
  }
  </code></pre>
  
  <p>Here is the trace when it happened:</p>
  
  <pre><code>java.lang.RuntimeException: Package manager has died
  at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:78)
  </code></pre>