Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android - Open with/Share with popup does not appear and no app opens
Forum Updated to NodeBB v4.3 + New Features

Android - Open with/Share with popup does not appear and no app opens

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 791 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ebonnett
    wrote on 15 Jun 2018, 14:21 last edited by
    #1

    Hi all,

    Can anyone offer any insight as to why the "Open with" or "Share with" popup doesn't appear on my phones with Android 8.X phones but it does on my Note 4 with 6.X on it?

    Here is my situation:

    I have a Qt app that generates a pdf and displays it to the user. On my Nexus 6P and my S9, it generates the pdf but does not open it in the pdf viewer. The "Open with" doesn't even come up. Also, I have a button that is supposed to email the pdf but when I touch the email button, nothing happens.

    It used to work and still does on Android 6.X. I have a 7.X phone and will test to see if it works on that and update this question but has anyone had this problem and figured it out?

    R 1 Reply Last reply 15 Jun 2018, 20:37
    0
    • E ebonnett
      15 Jun 2018, 14:21

      Hi all,

      Can anyone offer any insight as to why the "Open with" or "Share with" popup doesn't appear on my phones with Android 8.X phones but it does on my Note 4 with 6.X on it?

      Here is my situation:

      I have a Qt app that generates a pdf and displays it to the user. On my Nexus 6P and my S9, it generates the pdf but does not open it in the pdf viewer. The "Open with" doesn't even come up. Also, I have a button that is supposed to email the pdf but when I touch the email button, nothing happens.

      It used to work and still does on Android 6.X. I have a 7.X phone and will test to see if it works on that and update this question but has anyone had this problem and figured it out?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 15 Jun 2018, 20:37 last edited by
      #2

      @ebonnett
      now the question how do you open the intent exactly?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • E Offline
        E Offline
        ebonnett
        wrote on 18 Jun 2018, 13:14 last edited by
        #3

        Here is the code I'm using in a .java file

        boolean sendMail(String emailSubject, String emailBody, String emailRecipient, String attachmentFilename)
        {
        try
        {
        System.out.println("sendMail...");
        String f = "file://" + attachmentFilename;

                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("message/rfc822");
                intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
                intent.putExtra(Intent.EXTRA_TEXT, emailBody);
                intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailRecipient});
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                    java.io.File file = new java.io.File(attachmentFilename);
                    Uri apkURI = FileProvider.getUriForFile(
                            _parentContext,
                            _parentContext.getApplicationContext()
                                    .getPackageName() + ".provider", file);
        
                    intent.putExtra(Intent.EXTRA_STREAM, apkURI);
                }
                else
                {
                    Uri uri = Uri.parse(f);
                    intent.putExtra(Intent.EXTRA_STREAM, uri);
                }
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                Intent mailer = Intent.createChooser(intent, null);
                if (mailer == null)
                {
                    System.out.println("sendMail no mailer... ");
                    return false;
                }
        
                _parentContext.startActivity(mailer);
            }
            catch (Exception  ex)
            {
                System.out.println("sendMail exception... ");
                ex.printStackTrace();
                return false;
            }
        
            return true;
        }
        
        boolean openPdf(String filename) 
        {
            try 
            {
                Uri apkURI = null;
                java.io.File file = new java.io.File(filename);
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) 
                {
        
                    apkURI = FileProvider.getUriForFile(
                            _parentContext,
                            _parentContext.getApplicationContext()
                                    .getPackageName() + ".provider", file);
                } 
                else 
                {
                    apkURI = Uri.fromFile(file);
                }
            
                Intent intentUrl = new Intent(Intent.ACTION_VIEW);
                intentUrl.setDataAndType(apkURI, "application/pdf");
                intentUrl.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intentUrl.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                _parentContext.startActivity(intentUrl);
            } 
            catch (Exception e) 
            {
                System.out.println("pdfopen exception... ");
                e.printStackTrace();
                return false;
            }
        
            return true;
        }
        
        1 Reply Last reply
        0
        • E Offline
          E Offline
          ebonnett
          wrote on 18 Jun 2018, 17:37 last edited by
          #4

          So I figured out the problem. I had some java files in my Qt project (C++). When I changed the package name, it wreaked havoc on all kinds of things. I had my java files in a package that matched the android package name. So I changed the java package to reflect the new android package name but did not see that there were "magic" strings to load the class into the QAndroidJniObject. That was causing the APK to crash ultimately but it also caused the Open With popups to not show.

          1 Reply Last reply
          3

          1/4

          15 Jun 2018, 14:21

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved