示例#1
0
  private void downloadXWalkApk() {
    // The download url is defined by the meta-data element with the name "xwalk_apk_url"
    // inside the application tag in the Android manifest. It can also be specified via
    // the option --xwalk-apk-url of the script make_apk.
    if (mXWalkApkUrl == null) {
      mXWalkApkUrl = getXWalkApkUrl();
      Log.d(TAG, "Crosswalk APK download URL: " + mXWalkApkUrl);
    }

    if (!mXWalkApkUrl.isEmpty()) {
      XWalkLibraryLoader.startDownload(new ForegroundListener(), mActivity, mXWalkApkUrl);
      return;
    }

    try {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      mActivity.startActivity(intent.setData(Uri.parse(XWALK_APK_MARKET_URL)));

      Log.d(TAG, "Market opened");
      mDialogManager.dismissDialog();
    } catch (ActivityNotFoundException e) {
      Log.d(TAG, "Market open failed");
      mDialogManager.showMarketOpenError(mCancelCommand);
    }
  }