Nominate our 2022 Qt Champions!

[Android + Qt 5.2 beta ] Unable to call Android Java class from c++

  • I'm enable to call android java class from c++,
    I tried to follow the below link, but it didn't work

    @#include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"
    #include <QtDebug>
    #include <QQmlContext>
    int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    NotificationClient *notificationClient = new NotificationClient(&viewer);
    viewer.rootContext()->setContextProperty("notificationClient", notificationClient);
    return app.exec();


    my java code is :

    @package org.qtproject.example.notification;

    import android.os.Bundle;
    import android.util.Log;
    import android.view.Menu;

    public class NotificationClient extends Activity {

    protected void onCreate(Bundle savedInstanceState) {

    public static void notify(String s){
    Log.d("notify", "0000000000000");

    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;


  • Instead of calling it from c++, I changed the generated Java code it and it worked as charm ;)

Log in to reply