Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Page stops answering after returning from opening an Intent to read pdf

$
0
0

My app downloads and opens a pdf file.
After I return to my application my renderer goes to a deadlock.
Since its a blank page I try to press back button by code but doesn't do anything because the interface is lock.
I try to manually click the navigation's back arrow but doesnt do anything either.

I don't get any exception.

Im using a component ANDHUD for the dialogs.

private void OpenPdfFile(string filePath)
        {
            activity = this.Context as Activity;

            try
            {

                if (File.Exists(filePath))
                {
                    global::Android.Net.Uri fileUri = global::Android.Net.Uri.Parse("file://" + filePath);

                    pdfIntent = new Intent(Intent.ActionView);
                    pdfIntent.SetType("application/pdf");
                    pdfIntent.SetData(fileUri);

                    pdfIntent.SetDataAndType(fileUri, "application/pdf");
                    pdfIntent.SetFlags(ActivityFlags.GrantReadUriPermission);
                    pdfIntent.SetFlags(ActivityFlags.NoHistory);
                    pdfIntent.SetFlags(ActivityFlags.ClearTop);
                    activity.StartActivity(pdfIntent);

                }
                //AndHUD.Shared.Dismiss();
            }
            catch (ActivityNotFoundException exc)
            {
                Console.WriteLine("Open Pdf exception: " + exc);
                AndHUD.Shared.Dismiss();
                ShowHud_Droid newAlertD = new ShowHud_Droid();
                newAlertD.ShowErrorOverlay(
                    translater.GetString("FAIL_OPEN_PDF_APP", new Dictionary<string, string>())
                );
            }
            catch (Exception exc)
            {
                Console.WriteLine("Open Pdf exception: " + exc);
                AndHUD.Shared.Dismiss();
                ShowHud_Droid newAlertD = new ShowHud_Droid();
                newAlertD.ShowErrorOverlay(
                    translater.GetString("FAIL_OPEN_PDF", new Dictionary<string, string>())
                );
            }
            finally
            {
                activity.OnBackPressed();
                Console.WriteLine("Open Pdf checkpoint 1");
            }
        }

--- EDIT ---

At android console each time I press hardware back button I get "write_int failed to open -1"
The navigation back doesn't say anything.


Viewing all articles
Browse latest Browse all 58056

Trending Articles