java-native-interface

Using existing shared library (.so) in Android application

别来无恙 提交于 2020-01-12 05:02:05
问题 I have the follow scenario to work on. I was given a shared library (libeffect.so) to use in a Android project i am working for a client. I dont have the shared library source code, i have just the .so file with me. The library is pre-compiled to work on android devices. Along with the shared library I have the method signature public static native void doEffect(int param1, IntBuffer intBuffer); So now I have some questiosn on how to make the call to this native method, of source, if this is

is there any ble api in Ndk

荒凉一梦 提交于 2020-01-11 13:13:31
问题 Can we use Ble hardware(Bluetooth low energy) direct from Ndk without any java interface. I am new to NDk. So I don't know about jni, or Ndk. I want to control the bluetooth hardware directly from native code , 回答1: NO and YES. NO: There is no BLE API in ndk. YES: You can talk to BT hardware from C code. In AOSP, look under <>/hardware/libhardware/include/hardware/ there are a bunch of headers. bluetooth.h defines the interface for Android's bluetooth module. Bluedroid implements it. You

is there any ble api in Ndk

此生再无相见时 提交于 2020-01-11 13:13:07
问题 Can we use Ble hardware(Bluetooth low energy) direct from Ndk without any java interface. I am new to NDk. So I don't know about jni, or Ndk. I want to control the bluetooth hardware directly from native code , 回答1: NO and YES. NO: There is no BLE API in ndk. YES: You can talk to BT hardware from C code. In AOSP, look under <>/hardware/libhardware/include/hardware/ there are a bunch of headers. bluetooth.h defines the interface for Android's bluetooth module. Bluedroid implements it. You

Weird: can not change the value of Integer in jni

我是研究僧i 提交于 2020-01-11 09:32:10
问题 I write a jni function to set the value of two java Integer object in C, just like this: jni_do_something(JNIEnv *env, jobject thiz, jobject p1, jobject p2) { jclass c; jfieldID id; c = env->FindClass("java/lang/Integer"); if (c==NULL) { LOGD("FindClass failed"); return -1; } id = env->GetFieldID(c, "value", "I"); if (id==NULL) { LOGD("GetFiledID failed"); return -1; } env->SetIntField(p1, id, 5); env->SetIntField(p2, id, 10); return 0; } In java, I called this function: native int do

Weird: can not change the value of Integer in jni

爷,独闯天下 提交于 2020-01-11 09:32:06
问题 I write a jni function to set the value of two java Integer object in C, just like this: jni_do_something(JNIEnv *env, jobject thiz, jobject p1, jobject p2) { jclass c; jfieldID id; c = env->FindClass("java/lang/Integer"); if (c==NULL) { LOGD("FindClass failed"); return -1; } id = env->GetFieldID(c, "value", "I"); if (id==NULL) { LOGD("GetFiledID failed"); return -1; } env->SetIntField(p1, id, 5); env->SetIntField(p2, id, 10); return 0; } In java, I called this function: native int do

JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)

♀尐吖头ヾ 提交于 2020-01-11 05:18:05
问题 I'm trying to use JNI and getting java.lang.UnsatisfiedLinkError. Unlike the other million questions asked about this, I have the lib on my path, and have even seen the exception change when I remove it. I'm sure that something is wrong with the dll I have created, but I'm not sure what. Here is my java class code: package com; public class Tune { static { System.loadLibrary("lala"); } public static void main(String[] args) { Tune j = new Tune(); System.out.println("2+6="+j.add(2, 6)); }

faster Math.exp() via JNI?

这一生的挚爱 提交于 2020-01-11 04:40:07
问题 I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java 's Math.exp() ?? I tried just jni + C, but it's slower than just plain java . 回答1: +1 to writing your own exp() implementation. That is, if this is really a bottle-neck in your application. If you can deal with a little inaccuracy, there are a number of extremely efficient exponent estimation algorithms out there, some of them dating back centuries. As I understand it, Java

Getting Java and TWAIN to play together nicely [closed]

此生再无相见时 提交于 2020-01-10 08:58:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of Morena and JTwain, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool. Is anyone familiar with a free tool that

Access to raw data in ARGB_8888 Android Bitmap

◇◆丶佛笑我妖孽 提交于 2020-01-09 18:06:55
问题 I am trying to access the raw data of a Bitmap in ARGB_8888 format on Android, using the copyPixelsToBuffer and copyPixelsFromBuffer methods. However, invocation of those calls seems to always apply the alpha channel to the rgb channels. I need the raw data in a byte[] or similar (to pass through JNI; yes, I know about bitmap.h in Android 2.2, cannot use that). Here is a sample: // Create 1x1 Bitmap with alpha channel, 8 bits per channel Bitmap one = Bitmap.createBitmap(1,1,Bitmap.Config.ARGB

Access to raw data in ARGB_8888 Android Bitmap

↘锁芯ラ 提交于 2020-01-09 18:04:12
问题 I am trying to access the raw data of a Bitmap in ARGB_8888 format on Android, using the copyPixelsToBuffer and copyPixelsFromBuffer methods. However, invocation of those calls seems to always apply the alpha channel to the rgb channels. I need the raw data in a byte[] or similar (to pass through JNI; yes, I know about bitmap.h in Android 2.2, cannot use that). Here is a sample: // Create 1x1 Bitmap with alpha channel, 8 bits per channel Bitmap one = Bitmap.createBitmap(1,1,Bitmap.Config.ARGB