Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Call C++ function from android BroadcastReceiver



  • Hi.
    I have an android application written in Qt. It has a BroadcastReceiver which receives incoming calls and shows a custom activity written in java.
    Is it possible to call C++/Qt function and run native code, in that activity? How? (I want to access ciphered database from Qt)
    Qt program may not be running while receiving BroadcastReceiver.

    Thanks



  • You can call C++/Qt to native code with JNI, here is link to start
    http://doc.qt.io/qt-5/android-support.html
    and this is good example to start with Qt Android : http://doc.qt.io/qt-5/qtandroidextras-notification-example.html



  • I know how to call C++/Qt function from android.
    But In this case Qt application is not running, while broadcast receiver receives signal from Android.



  • @MajidKamali

    Hi,

    have you found a solution for this one? I am trying to do something similar.

    Have a nice day,
    Bernhard



  • Hello.

    See example:
    Qt\Examples\Qt-5.7\androidextras\notification

    Qt\Examples\Qt-5.7\androidextras\notification\android-sources\src\org\qtproject\example\notification\NotificationClient.java

    This class extends
    public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity

    In other words this is your activity , add BroadcastReceiver there.

    Check that there is a change in AndroidManifest.xml

    android:name="org.qtproject.example.notification.NotificationClient"

    Where this class becomes its main activity.

    I have helped .


Log in to reply