Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Android + Qt 5.2 beta ] Unable to call Android Java class from c++

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

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmad88me
    wrote on 2 Dec 2013, 16:54 last edited by
    #1

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

    http://doc-snapshot.qt-project.org/qt5-stable/qtandroidextras-notification-example.html

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

    QtQuick2ApplicationViewer viewer;
    NotificationClient *notificationClient = new NotificationClient(&viewer);
    viewer.rootContext()->setContextProperty("notificationClient", notificationClient);
    viewer.setMainQmlFile&#40;QStringLiteral("qml/qttest/main.qml"&#41;);
    viewer.showExpanded();
    
    return app.exec();
    

    }
    @

    my java code is :

    @package org.qtproject.example.notification;

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

    public class NotificationClient extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.ff);
    }

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

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

    }
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ahmad88me
      wrote on 5 Jan 2014, 11:46 last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved