Important: Please read the Qt Code of Conduct -

How to handle filter-intent on android properly on Android

  • Qt Champions 2020


    I have registered my custom URI scheme to launch my application:

                   <action android:name=\"android.intent.action.VIEW\" />
                   <category android:name=\"android.intent.category.DEFAULT\" />
                   <category android:name=\"android.intent.category.BROWSABLE\" />
                   <data android:scheme=\"https\" android:host=\"\" />

    So, when the user clicked on following URL: then my application starts sucessfully. And I need to "intercept" this URL in my Qt application.

    In my activity I have re-implemented this methods:

        public void onCreate(Bundle savedInstanceState) {
            Intent intent = getIntent();
            Log.d(TAG, "On create intent: " + intent);
            String uri = intent.getDataString();
        protected void onNewIntent(Intent intent) {
            Log.d(TAG, "On new intent: " + intent);
            String uri = intent.getDataString();
        public static native void handleUrl(String url); // <<< This is static JNI method (it emits the Qt signal)

    A problem occurs when my application was not started in a moment when the user clicked on that URL. In this case gets called the JAVA's onCreate() method (instead of onNewIntent() method). And this does before than QApplication instance will be created. So, I can't emit any signals.

    I tried to store the received URL's to the Q_GLOBAL_STATIC variable when the handleUrl() gets called, and to read this Q_GLOBAL_STATIC variable after the QApplication gets constructed. But problem is that that Q_GLOBAL_STATIC variable has different instances (pointers) in both cases, and inside QCoreApplication that variable is empty.

    Does anybody faced with 'intent-filters' on Android && Qt?

  • Qt Champions 2016

  • Qt Champions 2020

    Many thanks, it was very useful link.

  • @kuzulis if your issue is solved, please don't forget to mark your post as such! Thanks

  • Qt Champions 2020

    Yes, of course. But I'm just don't tried nothing yet. :)

Log in to reply