Calling Android functions from Qt

To call an Android function from Qt, we need to follow a few steps:

  1. Create an empty Qt Quick project, which we have done countless times.
  2. Open the project file (.pro) and add the following androidextras module to the project:
QT += quickandroid: QT += androidextrasCONFIG += c++11
  1. Create AndroidManifest.xml and other important Android files by clicking on the Create Template button, which we learned about in the previous Deploying applications to Android devices section
  2. Then, create a MyToast.java file in your Qt project directory and open it up using Qt Creator. You must place it in the Android folder where you store your AndroidManifest.xml and make sure the folder structure looks like the following ...

Get Application Development with Qt Creator now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.