Example #1
0
        /// <summary>
        /// Processes the given intent, loading files passed using content resolver.
        /// </summary>
        /// <param name="intent">intent to process</param>
        private void ProcessIntent(Intent intent)
        {
            var app = Core.App.Current as Core.App;

            if (intent.DataString != null &&
                intent.DataString.StartsWith(Shared.Model.AppResourceUri.DefaultScheme))
            {
                Core.App.RunOnUiThread(async() => await app.OpenAppResourceUriAsync(intent.DataString));
                return;
            }

            var helper = new IntentFilterHelper(this.ContentResolver);

            string filename = Path.GetFileName(helper.GetFilenameFromIntent(intent));

            if (filename == null)
            {
                return;
            }

            var stream = helper.GetStreamFromIntent(intent);

            if (stream != null)
            {
                Core.App.RunOnUiThread(async() => await app.OpenFileAsync(stream, filename));
            }
        }
Example #2
0
        /// <summary>
        /// Processes the given intent, loading files passed using content resolver.
        /// </summary>
        /// <param name="intent">intent to process</param>
        private void ProcessIntent(Intent intent)
        {
            try
            {
                if (intent.DataString != null &&
                    intent.DataString.StartsWith(Shared.Model.AppResourceUri.DefaultScheme))
                {
                    Core.App.OpenAppResourceUri(intent.DataString);
                    return;
                }

                var helper = new IntentFilterHelper(this.ContentResolver);

                string filename = Path.GetFileName(helper.GetFilenameFromIntent(intent));
                if (filename == null)
                {
                    return;
                }

                var stream = helper.GetStreamFromIntent(intent);

                if (stream != null)
                {
                    Core.App.RunOnUiThread(async() => await OpenFileHelper.OpenFileAsync(stream, filename));
                }
            }
            catch (Exception)
            {
                // ignore errors
            }
        }