Beispiel #1
0
    private IEnumerator CheckApkUpdate()
    {
        bool needUpdate = !string.IsNullOrEmpty(currentPlatform.ApkDownloadUrl);

        if (needUpdate)
        {
            string apkPath = string.Format("{0}main_fuck_{1}_{2}.apk", GameConstant.PersistentDataPath, DeviceInfo.GameVersion, SDKManager.Instance.Platform);
            if (File.Exists(apkPath))
            {
                DownloadUtil.InstallAPK(apkPath);
            }
            else
            {
                if (!string.IsNullOrEmpty(currentPlatform.WebDownloadUrl))
                {
                    Application.OpenURL(currentPlatform.WebDownloadUrl);
                }
                else
                {
                    yield return(StartCoroutine(DownLoadApk(currentPlatform.ApkDownloadUrl, apkPath)));
                }
            }
        }
        else
        {
            yield return(StartCoroutine(CheckAsset()));
        }
    }
Beispiel #2
0
    private IEnumerator DownLoadApk(string sourcePath, string destPath)
    {
        using (WWW www = new WWW(sourcePath))
        {
            yield return(www);

            if (null != www.error)
            {
                Logger.LogError("down load apk failed source path = " + sourcePath);
                yield break;
            }

            DownloadUtil.WriteFile(www.bytes, destPath);
        }

        DownloadUtil.InstallAPK(destPath);
    }