[Android + Qt 5.2 beta ] Unable to call Android Java class from c++
-
wrote on 2 Dec 2013, 16:54 last edited by
I'm enable to call android java class from c++,
I tried to follow the below link, but it didn't workhttp://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(QStringLiteral("qml/qttest/main.qml")); 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;
}}
@ -
wrote on 5 Jan 2014, 11:46 last edited by
Instead of calling it from c++, I changed the generated Java code it and it worked as charm ;)