Android NDK:如何在C/C ++中隐含Java api函数
问题描述:
大家好,
我正在使用Java api在android ndk中工作.请帮助我.
我在NativeLib.java中的代码
Hi all,
i am working in android ndk using java api.Please help me.
My code in NativeLib.java
package com.marakana;
import android.R.bool;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
public class NativeLib {
static {
System.loadLibrary("ndk_demo");
}
Context mContext;
public NativeLib(NDKDemo ndkDemo) {
}
public void Keyboard(Context mContext){
this.mContext = mContext;
}
public void getSystemService(bool makevisible){
if(makevisible != null){
InputMethodManager m = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
else
{
InputMethodManager m = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(0, 0);
}
}
public native void openKeyBoard();
}
com_marakana_NativeLib.h
com_marakana_NativeLib.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_marakana_NativeLib */
#ifndef _Included_com_marakana_NativeLib
#define _Included_com_marakana_NativeLib
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_marakana_NativeLib
* Method: add
* Signature: (II)I
*/
JNIEXPORT jstring JNICALL Java_com_marakana_NativeLib_openKeyBoard
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
1.如何在c/c ++中实现Java函数
2.如何通过java调用c ++函数来显示键盘.
请帮帮我.
1.How to impliment java function in c/c++
2.how to call c++ function by java for display keyboard.
Please help me.
Thanks in advace.
答
如果您需要学习如何使用JNI,请参阅 ^ ].
我注意到这是您第四次询问基本相同的问题,那么到目前为止您实际尝试了什么,获得了什么结果?
If you need to learn how to use the JNI then see the developers guide[^].
I notice that this is the fourth time you have asked what is, essentially, the same question, so what have you actually tried up to now and what results have you obtained?