Hi all,
Currently I have a little trouble regarding cocos thread, jni thread, GLthread, main thread , ui thread … ?
If I want to integrate third party lib on Android Platform , the best way I should write everything in AppActivity.java to make it run on Main Thread right ? ( for me , I created XXXHepler Class with some public static functions , I don’t know what thread it is working on )
As I know , JNIThread is another thread completely independent from the main thread ! If I want to run the java code in main thread , I need to call
//context = AppActivity.getContext()
public static void functionNoReturnValue(){
Handler mainHandler = new Handler(context.getMainLooper());
mainHandler.post(new Runnable() {
@Override
public void run() {
// run code
}
});
but If I want to call one functon with return value in main thread , What should I do ?
Example:
//context = AppActivity.getContext()
public static double functionReturnValue(){
double result = 0.0;
Handler mainHandler = new Handler(context.getMainLooper());
mainHandler.post(new Runnable() {
@Override
public void run() {
// run code
result = getDoubleFunctionInMainThread();
}
});
return result; // It always return 0.0
}
Thanks