/// <summary>
        /// The get expansion files.
        /// </summary>
        /// <returns>
        /// The get expansion files.
        /// </returns>
        private bool GetExpansionFiles()
        {
            bool result = false;

            try
            {
                // Build the intent that launches this activity.
                Intent launchIntent = Intent;
                var    intent       = new Intent(this, typeof(ExpansionDownloaderActivity));
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                intent.SetAction(launchIntent.Action);

                if (launchIntent.Categories != null)
                {
                    foreach (string category in launchIntent.Categories)
                    {
                        intent.AddCategory(category);
                    }
                }

                // Build PendingIntent used to open this activity when user
                // taps the notification.
                Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetActivity(
                    this, 0, intent, Android.App.PendingIntentFlags.UpdateCurrent);

                // Always force download of LVL
                DownloadsDB.GetDB(this).UpdateMetadata(0, 0);
                // Request to start the download
                DownloaderServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired(
                    this, pendingIntent, typeof(ExpansionDownloaderService));

                // The DownloaderService has started downloading the files,
                // show progress otherwise, the download is not needed so  we
                // fall through to starting the actual app.
                if (startResult != DownloaderServiceRequirement.NoDownloadRequired)
                {
                    InitializeDownloadUi();
                    result = true;
                }
            }
            catch (PackageManager.NameNotFoundException e)
            {
#if DEBUG
                Android.Util.Log.Debug(Tag, "Cannot find own package!");
#endif
                e.PrintStackTrace();
            }
#pragma warning disable 168
            catch (Exception ex)
#pragma warning restore 168
            {
                // ignored
#if DEBUG
                Android.Util.Log.Debug(Tag, "Exception: ", EdiabasLib.EdiabasNet.GetExceptionText(ex));
#endif
            }

            return(result);
        }
 public override void OnReceive(Context context, Intent intent)
 {
     try
     {
         DownloaderService.StartDownloadServiceIfRequired(context, intent, typeof(LibraryDownloaderService));
     }
     catch (PackageManager.NameNotFoundException e)
     {
         e.PrintStackTrace();
     }
 }
Пример #3
0
        /// <summary>
        /// The get expansion files.
        /// </summary>
        /// <returns>
        /// The get expansion files.
        /// </returns>
        private bool GetExpansionFiles()
        {
            bool result = false;

            try
            {
                // Build the intent that launches this activity.
                Intent launchIntent = this.Intent;
                var    intent       = new Intent(this, typeof(SampleDownloaderActivity));
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                intent.SetAction(launchIntent.Action);

                if (launchIntent.Categories != null)
                {
                    foreach (string category in launchIntent.Categories)
                    {
                        intent.AddCategory(category);
                    }
                }

                // Build PendingIntent used to open this activity when user
                // taps the notification.
                PendingIntent pendingIntent = PendingIntent.GetActivity(
                    this, 0, intent, PendingIntentFlags.UpdateCurrent);

                // Request to start the download
                DownloadServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired(
                    this, pendingIntent, typeof(SampleDownloaderService));

                // The DownloaderService has started downloading the files,
                // show progress otherwise, the download is not needed so  we
                // fall through to starting the actual app.
                if (startResult != DownloadServiceRequirement.NoDownloadRequired)
                {
                    this.InitializeDownloadUi();
                    result = true;
                }
            }
            catch (PackageManager.NameNotFoundException e)
            {
                Debug.WriteLine("Cannot find own package! MAYDAY!");
                e.PrintStackTrace();
            }

            return(result);
        }
Пример #4
0
        private void StartExpansionDownload()
        {
            //("MainActivity.StartExpansionDownload");
            Intent intent  = this.Intent;
            Intent intent2 = new Intent(this, typeof(SMainActivity));

            intent2.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
            intent2.SetAction(intent.Action);
            if (intent.Categories != null)
            {
                foreach (string category in intent.Categories)
                {
                    intent2.AddCategory(category);
                }
            }
            PendingIntent activity = PendingIntent.GetActivity(this, 0, intent2, PendingIntentFlags.UpdateCurrent);

            try
            {
                DownloaderServiceRequirement downloaderServiceRequirement = DownloaderService.StartDownloadServiceIfRequired(this, activity, typeof(ExpansionDownloaderService));
                if (downloaderServiceRequirement != 0)
                {
                    //("MainActivity.StartExpansionDownload A startResult:" + downloaderServiceRequirement);
                    this._downloaderServiceConnection = DownloaderClientMarshaller.CreateStub(this, typeof(ExpansionDownloaderService));
                    this._downloaderServiceConnection.Connect(this);
                    //("MainActivity.StartExpansionDownload B startResult:" + downloaderServiceRequirement);
                }
                else
                {
                    //("MainActivity.StartExpansionDownload - all files have finished downloading already");
                    this.OnExpansionDowloaded();
                }
            }
            catch (IllegalStateException ex)
            {
                //("MainActivity.StartExpansionDownload ERROR exception:" + ex);
                Crashes.TrackError(ex);
            }
        }
Пример #5
0
        private bool GetExpansionFiles()
        {
            bool result = false;

            // Build the intent that launches this activity.
            Intent launchIntent = this.Intent;
            var    intent       = new Intent(this, typeof(SuperSimpleActivity));

            intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
            intent.SetAction(launchIntent.Action);

            if (launchIntent.Categories != null)
            {
                foreach (string category in launchIntent.Categories)
                {
                    intent.AddCategory(category);
                }
            }

            // Build PendingIntent used to open this activity when user
            // taps the notification.
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);

            // Request to start the download
            DownloadServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired(this, pendingIntent, typeof(SampleDownloaderService));

            // The DownloaderService has started downloading the files,
            // show progress otherwise, the download is not needed so  we
            // fall through to starting the actual app.
            if (startResult != DownloadServiceRequirement.NoDownloadRequired)
            {
                this.downloaderServiceConnection = ClientMarshaller.CreateStub(this, typeof(SampleDownloaderService));

                result = true;
            }

            return(result);
        }
        private bool GetExpansionFiles()
        {
            bool result = false;

            try
            {
                Intent launchIntent = Intent;
                var    intent       = new Intent(this, typeof(LibraryDownloaderActivity));
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                intent.SetAction(launchIntent.Action);

                if (launchIntent.Categories != null)
                {
                    foreach (string category in launchIntent.Categories)
                    {
                        intent.AddCategory(category);
                    }
                }

                PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);

                DownloadServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired(this, pendingIntent, typeof(LibraryDownloaderService));

                if (startResult != DownloadServiceRequirement.NoDownloadRequired)
                {
                    InitializeDownloadUI();
                    result = true;
                }
            }
            catch (PackageManager.NameNotFoundException e)
            {
                Console.WriteLine("Cannot find own package! MAYDAY!");
                e.PrintStackTrace();
            }

            return(result);
        }
Пример #7
0
 public override void OnReceive(Android.Content.Context context, Intent intent)
 {
     DownloaderService.StartDownloadServiceIfRequired(context, intent, typeof(ExpansionDownloaderService));
 }
Пример #8
0
 public override void OnReceive(Context context, Intent intent)
 {
     DownloaderService.StartDownloadServiceIfRequired(context, intent, typeof(MyDownloaderService));
 }