android intents: how to get them?
-
wrote on 23 Oct 2024, 21:40 last edited by
My app is very normal, with a boring AndroidManifest.xml and the intent filter with the two lines to make it show up on the homescreen.
Now I want to add a second way for the app to start; namely when a scheme is activated.
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="secret" /> </intent-filter>
So, when a webpage asks for that scheme, my app should start.
The question is, how do I get hold of all the details. For instance if I listen to "tel" as the scheme and the full intent is "tel:12345". How do I get access to the '12345' ?
Anyone knows?
-
wrote on 26 Oct 2024, 21:28 last edited by
OK, the solution seems to be:
- Create a Java class to inherit QtActivity.
- Reimplement onNewIntent there
- Use QJniEnvironment.registerNativeMethods() and Java 'native' methods to allow passing in the intent or the data from that intent to the C++ code.
The documentation on the site is still far below general Qt level, but improving since 6.7 which I massively appreciate and I only managed to solve this by switching from the 6.5 docs to the 6.7 docs.
-
wrote on 23 Oct 2024, 21:59 last edited by
Maybe a better way of asking is: do I need to create a new activity in Java to be able to get hold of the intent, or does the default one allow me to get hold of it in C++?
-
wrote on 26 Oct 2024, 21:28 last edited by
OK, the solution seems to be:
- Create a Java class to inherit QtActivity.
- Reimplement onNewIntent there
- Use QJniEnvironment.registerNativeMethods() and Java 'native' methods to allow passing in the intent or the data from that intent to the C++ code.
The documentation on the site is still far below general Qt level, but improving since 6.7 which I massively appreciate and I only managed to solve this by switching from the 6.5 docs to the 6.7 docs.
-
1/3