native-code

How to create callbacks between android code and native code?

 ̄綄美尐妖づ 提交于 2019-11-30 05:22:05
I have a requirement for creating call backs between native code ( c language code) and Android code . I wrote JNI functions for calling C code from the android like this JNI code here #include <android/log.h> void initSocket(); #ifdef __cplusplus extern "C" { #endif JNIEXPORT void JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_initSocket(JNIEnv *jenv, jclass jcls) { __android_log_write(ANDROID_LOG_INFO, " JNI CODE ", " APP INIT SOCKET"); initSocket(); } } C code looks like this void initSocket() { /// some more stuff printf(" initSocket function "); } static int worker_thread(void *unused) { ///

Releasing Memory Allocated by Native Libraries in Java

 ̄綄美尐妖づ 提交于 2019-11-29 21:24:28
问题 If you are running code that makes calls to a native library in Java, what is the usual way of freeing memory allocated by these libraries when the memory allocation should last for the lifetime of the object? In C++, I would use destructors, but Java never really had those and has them even less now. The specific case I'm most interested in is JOCL, where I have an object that wraps a compiled OpenCL kernel and all of the arguments thereto that are always the same. Structures representing

How to create callbacks between android code and native code?

大城市里の小女人 提交于 2019-11-29 03:36:32
问题 I have a requirement for creating call backs between native code ( c language code) and Android code . I wrote JNI functions for calling C code from the android like this JNI code here #include <android/log.h> void initSocket(); #ifdef __cplusplus extern "C" { #endif JNIEXPORT void JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_initSocket(JNIEnv *jenv, jclass jcls) { __android_log_write(ANDROID_LOG_INFO, " JNI CODE ", " APP INIT SOCKET"); initSocket(); } } C code looks like this void initSocket()

How to Compile with ngen.exe and How to run the native code that is generated?

假如想象 提交于 2019-11-29 02:49:08
问题 I want to compile a C# program using ngen command line for a special purpose. So I create a console application in VS2010 and named it ngentest . A file by name ngentest.vshost.exe is created in vs2010\projects\ngentest\bin\debug . I used this file as a ngen command argument in VS2010 command prompt, as follows: ngen "c:\documents\vs2010\projects\ngentest\bin\debug\ngentest.vshost.exe" But when I do this, I can't receive PublicKeyToken and I couldn't find any assembly anywhere! If my assembly

Where can I find javascript native functions source code? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-28 09:24:58
This question already has an answer here: How to see the source of Built-in javascript functions? [closed] 1 answer where can I find the source code of native js functions, for example I want to look at eval() function In the JavaScript engine's source code. Both Chrome and Firefox are open source and you can look at the implementation of any part of the javascript engine in the source code for those products. Other browsers have their own implementation (like IE) that is not available to the public to look at. The Chrome v8 javascript engine is here: http://code.google.com/p/v8/ The Firefox

Android NativeActivity

心已入冬 提交于 2019-11-28 09:16:27
The Android NDK has just been significantly expanded to include support for writing android applications entirely in native C/C++ code. One can now capture input events on the keyboard and touch screen using native code, and also implement the application lifecycle in C/C++ using the new NativeActivity class. Given all the expanded native capabilities, would it be worthwhile to completely bypass Java and write Android application in native code? The NDK is not native per-se. It is to a large extent a JNI wrapper around the Android SDK. Using NativeActivity gives you a convenient way of dealing

Android : can native code get broadcast intent from android system? [duplicate]

ぐ巨炮叔叔 提交于 2019-11-28 06:04:15
This question already has an answer here: Listen to own application uninstall event on Android 3 answers Recently i've seen a funny app - Photo Wonder. When this app is uninstalled, it shows a web survey page asking for the reason of app uninstall. Now, here is the problem. As far as I know, after an app has been removed, the system broadcasts ACTION_PAKAGE_REMOVED intent. But this funny app was able to show my the web page although the official doc says "The package that is being installed does not receive this Intent." Anyhow, I could find a process checking some kind of status of the app.

Is it possible to use sun.misc.Unsafe to call C functions without JNI?

爱⌒轻易说出口 提交于 2019-11-28 04:10:47
A piece of C/C++ code could provide a JNI method with an array of function pointers. But is there a way to call to the stack the functions that array's pointers are pointing to, directly from inside Java code (without using JNI or similar)? JNI somehow does something like that, so there must be a way. How does JNI do it? Is it via sun.misc.Unsafe? Even if it is not, could we use some Unsafe workaround to get our hands on the JVM code that does that? I don't plan to use that commercially of course. I'm not even a professional, I just really enjoy coding and I've been studying CUDA lately so I

How to use OSGi fragments to contribute platform-dependent native code with the same filename?

坚强是说给别人听的谎言 提交于 2019-11-28 03:54:35
问题 I am using the JNotify project to listen to file system events. This depends on one native library per OS:processor architecture. For example, there's one library for Windows x86, one library for x86-64 etc. Monolithic bundle Originally, I had one bundle that contained both the JNotify Java classes and the native code. The native code were declared in Bundle-NativeCode as follows: (I've formatted these in the bnd style for better readibility... obviously the actual MANIFEST.MF files are

How to get Sampling rate and frequency of music file (MP3) in android?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 20:45:30
I am developing audio player in android. So i want to add the details of the playing song i.e. Artist Name, Duration, Bit rate and sampling frequency. I can get Artist Name and duration of a music file by using MediaStore.Audio.Media library . But i am unable to get Bit rate and sampling frequency of the same file. So how can i get the same? As i know, it can be done by using native library. But don't know how? So anyone can help me on this? You can approximate it by dividing the file size by the length of the audio in seconds, for instance, from a random AAC encoded M4A in my library: File