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. Unable to get java class from jni enviroment using android extras
Forum Updated to NodeBB v4.3 + New Features

Unable to get java class from jni enviroment using android extras

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    kranthi
    wrote on last edited by
    #1

    Hi,
    I wanted to create the object of a class as created in the class:

    QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification);

    QAndroidJniEnvironment jnienvironment;

    jclass myclass= jnienvironment->FindClass("org/qtproject/example/notification/NotificationClient");

    qDebug()<<"jni class object is >>"<<myclass; //unable to get the class of java here

    QAndroidJniObject nitificationObj(myclass);

    qDebug()<<"jni object is :"<<nitificationObj.toString();

    nitificationObj.callMethod<void>("notify", "(Ljava/lang/String;)V", javaNotification.object<jstring>());

    If use static method call then it is working. but, when i try to access the java class, it is not working. kindly provide the solution for this problem.

    Thanks and regards
    Krnathi Talluri

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      For using a java class into a Qt project with android extras, I simple do this:
      @
      // create the java object calling the constructor without any arguments
      QAndroidJniObject androidInterface("com/myproject/AndroidInterface");
      // then call a method specifying correctly all arguments
      jboolean result = androidInterface.callMethod<jboolean>("saveWhatever", "(Landroid/app/Activity;I)Z", activity, whatever);
      @

      And it works perfectly.

      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