To call an Android function from Qt, we need to follow a few steps:
- Create an empty Qt Quick project, which we have done countless times.
- Open the project file (.pro) and add the following androidextras module to the project:
QT += quickandroid: QT += androidextrasCONFIG += c++11
- 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.
- 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 ...