Click here to Skip to main content
15,886,199 members

Android NDK:how to impliment java api function in c/C++

Tn1111 asked:

Open original thread
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

C++
/* 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.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.
Tags: C++, Linux

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900