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. Qt5 to qt6 android QtNative.activity() replacement
Qt 6.11 is out! See what's new in the release blog

Qt5 to qt6 android QtNative.activity() replacement

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 1.7k Views
  • 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.
  • C Offline
    C Offline
    ConnorLee
    wrote on last edited by
    #1

    I have this java code:

    import org.qtproject.qt5.android.QtNative;
    
    public class QShareUtils
    {
    
       public static void share(String text, String url, Context context) {
           if (QtNative.activity() == null)
               return;
           Intent sendIntent = new Intent();
           sendIntent.setAction(Intent.ACTION_SEND);
           File outputFile = new File(url);
           Uri apkURI = FileProvider.getUriForFile(context, "com.name.provider", outputFile);
           sendIntent.setType("application/pdf");
           sendIntent.putExtra(Intent.EXTRA_STREAM, apkURI);
           QtNative.activity().startActivity(sendIntent);
       }
    }
    
    

    But after converting to qt6 it won't build because it is referencing qt5.android.QtNative.

    I've looked around the documentation and forums but I can't seem to find the replacement for this? Is there something obvious im missing?

    Any help would be greatly appreciated

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bataviasw
      wrote on last edited by
      #2

      It's just qt.android.native for Qt6, so:
      import org.qtproject.qt.android.bindings.QtActivity;

      1 Reply Last reply
      1

      • Login

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