• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

JNI question - c++ objects (global?) and returning arrays

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to run the native c++ code under android using NDK and JNI but I think this reffers to a JNI problem in general.
I guess I will start with explaining the functionality of my c++ code and then ask how can I transfer this to JAVA android app.

In my c++ code I do more less sth like the following (i don't want to go too specific into details):


So after all operations I have a float array named 'result' which has the size of 'size1'

Now my question Is how to transport this functionality to Android using NDK. MY ideas are:

1. Because I can't make the cppObject in Java application and it must 'remember' the results of each loop iteration I guess the only solution is to declare cppObject as a global in the JNI .cpp file - is this the right approach and how to do this?

2. I am not sure but I guess I have finally discovered how to pass an array of floats from JAVA to C++. Is this correct?


3. How to create a proper JNI function for this part:


So after I run the native method in Java I will have the same array as 'results' with size of 'size1'. So in other word - how to return the float * form c++ to JAVA app through JNI

I am spending hours after hours looking for a solution in the Internet so please can somebody help me?
 
Sheriff
Posts: 22209
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's move this to our Android forum.
 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah probably a better place - sorry for the trouble :>
 
Grow a forest with seedballs and this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic