Exemplo n.º 1
0
        /// <summary>
        /// Android method called first when an activity is reloaded after being paused and resumed by the Android OS.
        /// </summary>
        protected override async void OnResume()
        {
            base.OnResume();

            if (await webServiceControl.IsWebServiceReachableAsync())
            {
                RefreshAppList();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks for newer versions of the sp[ecified app on the server and returns it's details if any are found.
        /// </summary>
        /// <param name="appName">Name of the application</param>
        /// <param name="currentAppVersion">Current version of the app installed on the device.</param>
        private async Task <PackageDetails> CheckForNewVersion(String appName, String currentAppVersion)
        {
            try
            {
                if (String.IsNullOrEmpty(appName))
                {
                    return(null);
                }

                if (String.IsNullOrEmpty(currentAppVersion))
                {
                    return(null);
                }

                if (!await webServiceControl.IsWebServiceReachableAsync())
                {
                    Toast.MakeText(this, "Cannot reach the MOBU web service.", ToastLength.Long);
                    return(null);
                }
                else
                {
                    var packages = await webServiceControl.GetPackageListAsync();

                    packages = packages.Where(x => x.Name.Equals(appName, StringComparison.OrdinalIgnoreCase) && new Version(x.Version) > new Version(currentAppVersion) && x.Critical).ToList();

                    if (packages.Any())
                    {
                        return(packages.OrderByDescending(x => x.Version).First());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Info("MobuAndroid", "Error while checking for updates.", e.Message);
                return(null);
            }
        }