better calling of the JAVA (step 2)
This commit is contained in:
parent
cda5d8cd40
commit
751a0712d8
@ -17,6 +17,8 @@ import android.view.Window;
|
|||||||
|
|
||||||
// For the full screen :
|
// For the full screen :
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
// for the keyboard event :
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -36,7 +38,8 @@ import android.content.res.AssetManager;
|
|||||||
*/
|
*/
|
||||||
public class __PROJECT_NAME__ extends Activity {
|
public class __PROJECT_NAME__ extends Activity {
|
||||||
private static native void TouchEvent();
|
private static native void TouchEvent();
|
||||||
private static native void ActivitySetJavaVortualMachineStart();
|
private static native void ActivitySetJavaVortualMachineStart(__PROJECT_NAME__ ActivityInstance);
|
||||||
|
//private static native void ActivitySetJavaVortualMachineStart();
|
||||||
private static native void ActivitySetJavaVortualMachineStop();
|
private static native void ActivitySetJavaVortualMachineStop();
|
||||||
private static native void ActivityOnCreate();
|
private static native void ActivityOnCreate();
|
||||||
private static native void ActivityOnStart();
|
private static native void ActivityOnStart();
|
||||||
@ -51,14 +54,17 @@ public class __PROJECT_NAME__ extends Activity {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("__PROJECT_PACKAGE__");
|
System.loadLibrary("__PROJECT_PACKAGE__");
|
||||||
|
//ActivitySetInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onCreate(Bundle savedInstanceState)
|
@Override protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
// set the java evironement in the C sources :
|
// set the java evironement in the C sources :
|
||||||
ActivitySetJavaVortualMachineStart();
|
ActivitySetJavaVortualMachineStart(this);
|
||||||
|
//ActivitySetJavaVortualMachineStart();
|
||||||
|
|
||||||
// Load the application directory
|
// Load the application directory
|
||||||
ActivityParamSetArchiveDir(1, getFilesDir().toString());
|
ActivityParamSetArchiveDir(1, getFilesDir().toString());
|
||||||
@ -87,6 +93,10 @@ public class __PROJECT_NAME__ extends Activity {
|
|||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
// set full screen Mode :
|
// set full screen Mode :
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
// display keyboard:
|
||||||
|
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
|
// hide keyboard :
|
||||||
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||||
//Force landscape
|
//Force landscape
|
||||||
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
// create bsurface system
|
// create bsurface system
|
||||||
@ -138,23 +148,33 @@ public class __PROJECT_NAME__ extends Activity {
|
|||||||
// Remove the java Virtual machine pointer form the C code
|
// Remove the java Virtual machine pointer form the C code
|
||||||
ActivitySetJavaVortualMachineStop();
|
ActivitySetJavaVortualMachineStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected void finalize() throws Throwable
|
||||||
|
{
|
||||||
|
super.finalize();
|
||||||
|
// cleanup your object here
|
||||||
|
}
|
||||||
|
|
||||||
public void onConfigurationChanged(Configuration newConfig)
|
public void onConfigurationChanged(Configuration newConfig)
|
||||||
{
|
{
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eventFromCPP(String[] args)
|
public void CPP_keyboardShow()
|
||||||
{
|
{
|
||||||
if (args[0] == "Keyboard_Show") {
|
|
||||||
TouchEvent();
|
TouchEvent();
|
||||||
TouchEvent();
|
try{
|
||||||
TouchEvent();
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
} else if (args[0] == "Keyboard_Hide") {
|
} catch (Exception e) {
|
||||||
TouchEvent();
|
|
||||||
TouchEvent();
|
}
|
||||||
} else {
|
|
||||||
TouchEvent();
|
TouchEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void eventFromCPP(String[] args)
|
||||||
|
{
|
||||||
|
// just for the test ...
|
||||||
|
TouchEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,150 @@ void EWOL_NativeGLDestroy(void);
|
|||||||
// get a resources from the java environement :
|
// get a resources from the java environement :
|
||||||
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
||||||
static jclass javaClassActivity = 0; // main activity class (android ...)
|
static jclass javaClassActivity = 0; // main activity class (android ...)
|
||||||
|
static jobject javaObjectActivity = 0;
|
||||||
static jmethodID javaClassActivityEntryPoint = 0; // basic methode to call ...
|
static jmethodID javaClassActivityEntryPoint = 0; // basic methode to call ...
|
||||||
|
static jmethodID javaClassActivityEntryPoint__CPP_keyboardShow = 0; // basic methode to call ...
|
||||||
// generic classes
|
// generic classes
|
||||||
static jclass javaDefaultClassString = 0; // default string class
|
static jclass javaDefaultClassString = 0; // default string class
|
||||||
|
|
||||||
|
|
||||||
static JavaVM* g_JavaVM = NULL;
|
static JavaVM* g_JavaVM = NULL;
|
||||||
|
|
||||||
|
// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include
|
||||||
|
|
||||||
|
|
||||||
|
// for exemple test :
|
||||||
|
void displayKeyboard(bool pShow) {
|
||||||
|
// Attaches the current thread to the JVM.
|
||||||
|
jint lResult;
|
||||||
|
jint lFlags = 0;
|
||||||
|
|
||||||
|
JavaVM* lJavaVM = g_JavaVM;
|
||||||
|
JNIEnv* lJNIEnv = NULL;
|
||||||
|
|
||||||
|
int status = g_JavaVM->GetEnv((void **) &lJNIEnv, JNI_VERSION_1_6);
|
||||||
|
if (status == JNI_EDETACHED) {
|
||||||
|
JavaVMAttachArgs lJavaVMAttachArgs;
|
||||||
|
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
|
||||||
|
lJavaVMAttachArgs.name = "EwolNativeThread";
|
||||||
|
lJavaVMAttachArgs.group = NULL;
|
||||||
|
status = g_JavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs);
|
||||||
|
if (status != JNI_OK) {
|
||||||
|
APPL_DEBUG("C->java : AttachCurrentThread failed : " << status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (lResult == JNI_ERR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves NativeActivity.
|
||||||
|
jobject lNativeActivity = javaClassActivity;
|
||||||
|
jclass ClassNativeActivity = lJNIEnv->GetObjectClass(lNativeActivity);
|
||||||
|
|
||||||
|
// Retrieves Context.INPUT_METHOD_SERVICE.
|
||||||
|
jclass ClassContext = lJNIEnv->FindClass("android/content/Context");
|
||||||
|
jfieldID FieldINPUT_METHOD_SERVICE = lJNIEnv->GetStaticFieldID(ClassContext, "INPUT_METHOD_SERVICE", "Ljava/lang/String;");
|
||||||
|
jobject INPUT_METHOD_SERVICE = lJNIEnv->GetStaticObjectField(ClassContext, FieldINPUT_METHOD_SERVICE);
|
||||||
|
// TODO : jniCheck(INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
|
// Runs getSystemService(Context.INPUT_METHOD_SERVICE).
|
||||||
|
jclass ClassInputMethodManager = lJNIEnv->FindClass("android/view/inputmethod/InputMethodManager");
|
||||||
|
jmethodID MethodGetSystemService = lJNIEnv->GetMethodID(ClassNativeActivity, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
|
||||||
|
jobject lInputMethodManager = lJNIEnv->CallObjectMethod(lNativeActivity, MethodGetSystemService, INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
|
// Runs getWindow().getDecorView().
|
||||||
|
jmethodID MethodGetWindow = lJNIEnv->GetMethodID(ClassNativeActivity, "getWindow", "()Landroid/view/Window;");
|
||||||
|
jobject lWindow = lJNIEnv->CallObjectMethod(lNativeActivity, MethodGetWindow);
|
||||||
|
jclass ClassWindow = lJNIEnv->FindClass("android/view/Window");
|
||||||
|
jmethodID MethodGetDecorView = lJNIEnv->GetMethodID(ClassWindow, "getDecorView", "()Landroid/view/View;");
|
||||||
|
jobject lDecorView = lJNIEnv->CallObjectMethod(lWindow, MethodGetDecorView);
|
||||||
|
|
||||||
|
if (pShow) {
|
||||||
|
// Runs lInputMethodManager.showSoftInput(...).
|
||||||
|
jmethodID MethodShowSoftInput = lJNIEnv->GetMethodID( ClassInputMethodManager, "showSoftInput", "(Landroid/view/View;I)Z");
|
||||||
|
jboolean lResult = lJNIEnv->CallBooleanMethod(lInputMethodManager, MethodShowSoftInput, lDecorView, lFlags);
|
||||||
|
} else {
|
||||||
|
// Runs lWindow.getViewToken()
|
||||||
|
jclass ClassView = lJNIEnv->FindClass("android/view/View");
|
||||||
|
jmethodID MethodGetWindowToken = lJNIEnv->GetMethodID(ClassView, "getWindowToken", "()Landroid/os/IBinder;");
|
||||||
|
jobject lBinder = lJNIEnv->CallObjectMethod(lDecorView, MethodGetWindowToken);
|
||||||
|
// lInputMethodManager.hideSoftInput(...).
|
||||||
|
jmethodID MethodHideSoftInput = lJNIEnv->GetMethodID( ClassInputMethodManager, "hideSoftInputFromWindow", "(Landroid/os/IBinder;I)Z");
|
||||||
|
jboolean lRes = lJNIEnv->CallBooleanMethod( lInputMethodManager, MethodHideSoftInput, lBinder, lFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finished with the JVM.
|
||||||
|
lJavaVM->DetachCurrentThread();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SendJava_KeyboardShow(void)
|
||||||
|
{
|
||||||
|
APPL_DEBUG("C->java : call java");
|
||||||
|
if (NULL == g_JavaVM) {
|
||||||
|
APPL_DEBUG("C->java : JVM not initialised");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JNIEnv *JavaVirtualMachinePointer_tmp;
|
||||||
|
int status = g_JavaVM->GetEnv((void **) &JavaVirtualMachinePointer_tmp, JNI_VERSION_1_6);
|
||||||
|
if (status == JNI_EDETACHED) {
|
||||||
|
JavaVMAttachArgs lJavaVMAttachArgs;
|
||||||
|
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
|
||||||
|
lJavaVMAttachArgs.name = "EwolNativeThread";
|
||||||
|
lJavaVMAttachArgs.group = NULL;
|
||||||
|
status = g_JavaVM->AttachCurrentThread(&JavaVirtualMachinePointer_tmp, &lJavaVMAttachArgs);
|
||||||
|
if (status != JNI_OK) {
|
||||||
|
APPL_DEBUG("C->java : AttachCurrentThread failed : " << status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
|
APPL_DEBUG("C->java : EXEPTION ...");
|
||||||
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
|
APPL_DEBUG("C->java : EXEPTION ...");
|
||||||
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
APPL_DEBUG("C->java : 111");
|
||||||
|
if (NULL == JavaVirtualMachinePointer) {
|
||||||
|
APPL_DEBUG("C->java : JVM not initialised");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
APPL_DEBUG("C->java : 333");
|
||||||
|
//Call java ...
|
||||||
|
//JavaVirtualMachinePointer->CallVoidMethod(javaClassActivity, javaClassActivityEntryPoint__CPP_keyboardShow);
|
||||||
|
//JavaVirtualMachinePointer->CallStaticVoidMethod(javaClassActivity, javaClassActivityEntryPoint__CPP_keyboardShow);
|
||||||
|
JavaVirtualMachinePointer->CallVoidMethod(javaObjectActivity, javaClassActivityEntryPoint__CPP_keyboardShow);
|
||||||
|
|
||||||
|
|
||||||
|
APPL_DEBUG("C->java : 444");
|
||||||
|
// manage execption :
|
||||||
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
|
APPL_DEBUG("C->java : EXEPTION ...");
|
||||||
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finished with the JVM.
|
||||||
|
g_JavaVM->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
|
||||||
void SendSystemMessage(const char * dataString)
|
void SendSystemMessage(const char * dataString)
|
||||||
{
|
{
|
||||||
@ -60,84 +197,56 @@ void SendSystemMessage(const char * dataString)
|
|||||||
APPL_DEBUG("C->java : JVM not initialised");
|
APPL_DEBUG("C->java : JVM not initialised");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JNIEnv *JavaVirtualMachinePointer;
|
JNIEnv *JavaVirtualMachinePointer_tmp;
|
||||||
int status = g_JavaVM->GetEnv((void **) &JavaVirtualMachinePointer, JNI_VERSION_1_6);
|
int status = g_JavaVM->GetEnv((void **) &JavaVirtualMachinePointer_tmp, JNI_VERSION_1_6);
|
||||||
if (status == JNI_EDETACHED) {
|
if (status == JNI_EDETACHED) {
|
||||||
status = g_JavaVM->AttachCurrentThread(&JavaVirtualMachinePointer, NULL);
|
JavaVMAttachArgs lJavaVMAttachArgs;
|
||||||
|
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
|
||||||
|
lJavaVMAttachArgs.name = "EwolNativeThread";
|
||||||
|
lJavaVMAttachArgs.group = NULL;
|
||||||
|
status = g_JavaVM->AttachCurrentThread(&JavaVirtualMachinePointer_tmp, &lJavaVMAttachArgs);
|
||||||
if (status != JNI_OK) {
|
if (status != JNI_OK) {
|
||||||
APPL_DEBUG("C->java : AttachCurrentThread failed : " << status);
|
APPL_DEBUG("C->java : AttachCurrentThread failed : " << status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jclass javaClassActivity = JavaVirtualMachinePointer->FindClass("com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__" );
|
|
||||||
if (javaClassActivity == 0) {
|
|
||||||
APPL_DEBUG("C->java : Can't find com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__ class");
|
|
||||||
// remove access on the virtual machine :
|
|
||||||
JavaVirtualMachinePointer = NULL;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
jmethodID javaClassActivityEntryPoint = JavaVirtualMachinePointer->GetStaticMethodID(javaClassActivity, "eventFromCPP", "([Ljava/lang/String;)V" );
|
APPL_DEBUG("C->java : 111");
|
||||||
if (javaClassActivityEntryPoint == 0) {
|
|
||||||
APPL_DEBUG("C->java : Can't find com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__.eventFromCPP" );
|
|
||||||
// remove access on the virtual machine :
|
|
||||||
JavaVirtualMachinePointer = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
jclass javaDefaultClassString = JavaVirtualMachinePointer->FindClass("java/lang/String" );
|
|
||||||
if (javaDefaultClassString == 0) {
|
|
||||||
APPL_DEBUG("C->java : Can't find java/lang/String" );
|
|
||||||
// remove access on the virtual machine :
|
|
||||||
JavaVirtualMachinePointer = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// create the string to the java
|
|
||||||
jstring jstr = JavaVirtualMachinePointer->NewStringUTF(dataString);
|
|
||||||
if (jstr == 0) {
|
|
||||||
APPL_DEBUG("C->java : Out of memory" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// create argument list
|
|
||||||
jobjectArray args = JavaVirtualMachinePointer->NewObjectArray(1, javaDefaultClassString, jstr);
|
|
||||||
if (args == 0) {
|
|
||||||
APPL_DEBUG("C->java : Out of memory" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Call java ...
|
|
||||||
JavaVirtualMachinePointer->CallStaticVoidMethod(javaClassActivity, javaClassActivityEntryPoint, args);
|
|
||||||
|
|
||||||
// manage execption :
|
|
||||||
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
|
||||||
JavaVirtualMachinePointer->ExceptionDescribe();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
APPL_DEBUG("C->java : do nothing ... ");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (NULL == JavaVirtualMachinePointer) {
|
if (NULL == JavaVirtualMachinePointer) {
|
||||||
APPL_DEBUG("C->java : JVM not initialised");
|
APPL_DEBUG("C->java : JVM not initialised");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
APPL_DEBUG("C->java : 222");
|
||||||
|
if (NULL == dataString) {
|
||||||
|
APPL_DEBUG("C->java : No data to send ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APPL_DEBUG("C->java : 333");
|
||||||
// create the string to the java
|
// create the string to the java
|
||||||
jstring jstr = JavaVirtualMachinePointer->NewStringUTF(dataString);
|
jstring jstr = JavaVirtualMachinePointer->NewStringUTF(dataString);
|
||||||
if (jstr == 0) {
|
if (jstr == 0) {
|
||||||
APPL_DEBUG("C->java : Out of memory" );
|
APPL_DEBUG("C->java : Out of memory" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
APPL_DEBUG("C->java : 444");
|
||||||
// create argument list
|
// create argument list
|
||||||
jobjectArray args = JavaVirtualMachinePointer->NewObjectArray(1, javaDefaultClassString, jstr);
|
jobjectArray args = JavaVirtualMachinePointer->NewObjectArray(1, javaDefaultClassString, jstr);
|
||||||
if (args == 0) {
|
if (args == 0) {
|
||||||
APPL_DEBUG("C->java : Out of memory" );
|
APPL_DEBUG("C->java : Out of memory" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
APPL_DEBUG("C->java : 555");
|
||||||
//Call java ...
|
//Call java ...
|
||||||
JavaVirtualMachinePointer->CallStaticVoidMethod(javaClassActivity, javaClassActivityEntryPoint, args);
|
JavaVirtualMachinePointer->CallStaticVoidMethod(javaClassActivity, javaClassActivityEntryPoint, args);
|
||||||
|
|
||||||
|
APPL_DEBUG("C->java : 666");
|
||||||
// manage execption :
|
// manage execption :
|
||||||
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
if (JavaVirtualMachinePointer->ExceptionOccurred()) {
|
||||||
JavaVirtualMachinePointer->ExceptionDescribe();
|
JavaVirtualMachinePointer->ExceptionDescribe();
|
||||||
|
JavaVirtualMachinePointer->ExceptionClear();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
// Finished with the JVM.
|
||||||
|
g_JavaVM->DetachCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,12 +273,18 @@ extern "C"
|
|||||||
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityParamSetArchiveDir( JNIEnv* env, jobject thiz, jint mode, jstring myString)
|
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityParamSetArchiveDir( JNIEnv* env, jobject thiz, jint mode, jstring myString)
|
||||||
{
|
{
|
||||||
// direct setting of the date in the string system ...
|
// direct setting of the date in the string system ...
|
||||||
const char* str = env->GetStringUTFChars(myString,0);
|
jboolean isCopy;
|
||||||
|
const char* str = env->GetStringUTFChars(myString, &isCopy);
|
||||||
EWOL_ThreadSetArchiveDir(mode, str);
|
EWOL_ThreadSetArchiveDir(mode, str);
|
||||||
//env->ReleaseStringUTFChars(str,myString,0);
|
if (isCopy == JNI_TRUE) {
|
||||||
|
// from here str is reset ...
|
||||||
|
env->ReleaseStringUTFChars(myString, str);
|
||||||
|
str = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivitySetJavaVortualMachineStart( JNIEnv* env )
|
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivitySetJavaVortualMachineStart( JNIEnv* env, jclass classBase, jobject obj)
|
||||||
|
//void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivitySetJavaVortualMachineStart( JNIEnv* env)
|
||||||
{
|
{
|
||||||
APPL_DEBUG("*******************************************");
|
APPL_DEBUG("*******************************************");
|
||||||
APPL_DEBUG("** Set JVM Pointer **");
|
APPL_DEBUG("** Set JVM Pointer **");
|
||||||
@ -177,20 +292,30 @@ extern "C"
|
|||||||
JavaVirtualMachinePointer = env;
|
JavaVirtualMachinePointer = env;
|
||||||
// get default needed all time elements :
|
// get default needed all time elements :
|
||||||
if (NULL != JavaVirtualMachinePointer) {
|
if (NULL != JavaVirtualMachinePointer) {
|
||||||
javaClassActivity = JavaVirtualMachinePointer->FindClass("com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__" );
|
javaClassActivity = JavaVirtualMachinePointer->FindClass("com/__PROJECT_VENDOR__/__PROJECT_PACKAGE__/__PROJECT_NAME__" );
|
||||||
if (javaClassActivity == 0) {
|
if (javaClassActivity == 0) {
|
||||||
APPL_DEBUG("C->java : Can't find com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__ class");
|
APPL_DEBUG("C->java : Can't find com/__PROJECT_VENDOR__/__PROJECT_PACKAGE__/__PROJECT_NAME__ class");
|
||||||
// remove access on the virtual machine :
|
// remove access on the virtual machine :
|
||||||
JavaVirtualMachinePointer = NULL;
|
JavaVirtualMachinePointer = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// get the activity object :
|
||||||
javaClassActivityEntryPoint = JavaVirtualMachinePointer->GetStaticMethodID(javaClassActivity, "eventFromCPP", "([Ljava/lang/String;)V" );
|
javaClassActivityEntryPoint = JavaVirtualMachinePointer->GetStaticMethodID(javaClassActivity, "eventFromCPP", "([Ljava/lang/String;)V" );
|
||||||
if (javaClassActivityEntryPoint == 0) {
|
if (javaClassActivityEntryPoint == 0) {
|
||||||
APPL_DEBUG("C->java : Can't find com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__.__PROJECT_NAME__.eventFromCPP" );
|
APPL_DEBUG("C->java : Can't find com/__PROJECT_VENDOR__/__PROJECT_PACKAGE__/__PROJECT_NAME__.eventFromCPP" );
|
||||||
// remove access on the virtual machine :
|
// remove access on the virtual machine :
|
||||||
JavaVirtualMachinePointer = NULL;
|
JavaVirtualMachinePointer = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
javaClassActivityEntryPoint__CPP_keyboardShow = JavaVirtualMachinePointer->GetMethodID(javaClassActivity, "CPP_keyboardShow", "()V" );
|
||||||
|
if (javaClassActivityEntryPoint == 0) {
|
||||||
|
APPL_DEBUG("C->java : Can't find com/__PROJECT_VENDOR__/__PROJECT_PACKAGE__/__PROJECT_NAME__.CPP_keyboardShow" );
|
||||||
|
// remove access on the virtual machine :
|
||||||
|
JavaVirtualMachinePointer = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
javaObjectActivity = JavaVirtualMachinePointer->NewGlobalRef(obj);
|
||||||
|
|
||||||
javaDefaultClassString = JavaVirtualMachinePointer->FindClass("java/lang/String" );
|
javaDefaultClassString = JavaVirtualMachinePointer->FindClass("java/lang/String" );
|
||||||
if (javaDefaultClassString == 0) {
|
if (javaDefaultClassString == 0) {
|
||||||
APPL_DEBUG("C->java : Can't find java/lang/String" );
|
APPL_DEBUG("C->java : Can't find java/lang/String" );
|
||||||
@ -210,6 +335,10 @@ extern "C"
|
|||||||
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___TouchEvent( JNIEnv* env )
|
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___TouchEvent( JNIEnv* env )
|
||||||
{
|
{
|
||||||
APPL_DEBUG(" ==> Touch Event");
|
APPL_DEBUG(" ==> Touch Event");
|
||||||
|
if (env->ExceptionOccurred()) {
|
||||||
|
env->ExceptionDescribe();
|
||||||
|
env->ExceptionClear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnCreate( JNIEnv* env )
|
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnCreate( JNIEnv* env )
|
||||||
|
@ -247,13 +247,15 @@ void guiAbstraction::Stop(void)
|
|||||||
{
|
{
|
||||||
// TODo : send a message to the android system to stop ...
|
// TODo : send a message to the android system to stop ...
|
||||||
}
|
}
|
||||||
|
|
||||||
// java system to send message :
|
// java system to send message :
|
||||||
void SendSystemMessage(const char * dataString);
|
void SendSystemMessage(const char * dataString);
|
||||||
|
void SendJava_KeyboardShow(void);
|
||||||
|
|
||||||
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
|
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
|
||||||
{
|
{
|
||||||
// send a message at the java :
|
// send a message at the java :
|
||||||
SendSystemMessage("Keyboard_Show");
|
SendJava_KeyboardShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void guiAbstraction::KeyboardHide(void)
|
void guiAbstraction::KeyboardHide(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user