java-native-interface

Swing transparency using JNI

☆樱花仙子☆ 提交于 2020-01-14 06:14:46
问题 I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button instead of a JButton it works just fine. Native code: #include <windows.h> #include <jawt_md.h> #include <jawt.h> #include <jni.h> // Don't mangle names for the JVM extern "C" { BOOL

Swing transparency using JNI

痴心易碎 提交于 2020-01-14 06:13:05
问题 I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button instead of a JButton it works just fine. Native code: #include <windows.h> #include <jawt_md.h> #include <jawt.h> #include <jni.h> // Don't mangle names for the JVM extern "C" { BOOL

can i call java method from native code?if so how?

*爱你&永不变心* 提交于 2020-01-14 03:37:11
问题 I have a Java function which can take variable number of parameters and in JNI I am receiving all the parameters in jobjectArray. But the problem is all the parameters available in String type,but originally thy are of different datatype. So in c/c++ converting them to their original type is not possible. So if i could call some other java method which will make these conversions easy for me.is it possible in to call a java method from native code in JNI? Please help me out. I am really

c++ Plugin -> JNI --> Java Classpath

一世执手 提交于 2020-01-14 02:09:25
问题 i am trying to create a Plugin for an Application. The Plugin needs to be written in c++. I want to use the Plugin on Windows and on Mac, so it would be great to write the Plugin in Java. My Problem, there is an other Plugin using Java. Since they are using the same main Application there is already an running JavaVM. JavaVM *jvm = NULL; jsize jvm_count = 0; jint res=0; res = JNI_GetCreatedJavaVMs (&jvm, 1, &jvm_count); My Problem: How can i change / modify the Classpath of the existing

AudioRecord : How can I use a common buffer to use it for processing and storing?

半世苍凉 提交于 2020-01-13 17:08:54
问题 I have an AudioRecord thread that writes to database. Now I want to use some audio data in buffer at some intervals and process it using FFT . I want to send audio buffer to FFT as parameter. When I am trying to use a common buffer then its giving me libc error. How can I use a common buffer to pass it to FFT and also write it to a storage? When I tried using different read calls there was situation of data loss and hence cant use that. Following is my code public void start() {

Intents and onActivityResult in native/JNI

此生再无相见时 提交于 2020-01-13 14:54:36
问题 From this post one can see how to send an Intent from a native environment using JNI: jclass activityClass = jniEnv->FindClass("android/app/Activity"); jmethodID startAcitivtyMethod = jniEnv->GetMethodID(activityClass , "startActivity", "(Landroid/content/Intent;)V"); jniEnv->CallVoidMethod(yourActivityObject, startAcitivityMethod, yourIntentObject); but is it possible and how can one use startActivityForResult() instead of startActivity() and onActivityResult() to get the result of

How to expose a native enum to Java through JNI?

匆匆过客 提交于 2020-01-13 13:01:58
问题 I am importing headers from an existing project for a port to Android-NDK. In a few cases, there are enums defined in the native headers which I would like to use from the Java layer. How can one go about doing that? Ideally, I'd like to just expose the constants to the Java layer somehow, but I don't see a way to do that. The most obvious possibility is to doubly-define the enums in both Java and C++. However, the existing headers a) have no explicit numbering, b) have elements which are

How to expose a native enum to Java through JNI?

試著忘記壹切 提交于 2020-01-13 13:01:17
问题 I am importing headers from an existing project for a port to Android-NDK. In a few cases, there are enums defined in the native headers which I would like to use from the Java layer. How can one go about doing that? Ideally, I'd like to just expose the constants to the Java layer somehow, but I don't see a way to do that. The most obvious possibility is to doubly-define the enums in both Java and C++. However, the existing headers a) have no explicit numbering, b) have elements which are

How to keep a C++ object inside Java code? Possible?

偶尔善良 提交于 2020-01-13 02:44:26
问题 First I've got a legacy C++ library, and I'm migrating my app to Android with new UI. During runtime, there might be multiple C++ objects created and destroyed dynamically. I built a set of JNI native methods to call into library to get that. But where should I keep those C++ objects? I have to keep track of them and free them if they're unnecessary. So far I only knew Java can't reference to a C++ object. Is it possible to make a Java wrapper class which include a reference to C++ object?

Class name from jclass in JNI

元气小坏坏 提交于 2020-01-12 07:07:12
问题 This is probably a daft question that reveals a lack of understanding of JNI. I'm writing a C++ program that encapsulates the Java VM: I'm calling functions within the VM using calls such as CallVoidMethod. That's purely background and not very relevant to the question. I would like to be able to find the name of the Java class given a jclass instance. Is there any way to do this? Could I just call the GetName function, as I would in a Java program? 回答1: The jclass instance is your object on