[FIXED] How to get unsigned long long from C++ to Kotlin through JNI?

Issue

I’d like to read an unsigned long long from my Kotlin code.
The value comes from C++ code through JNI.

Here is the C++ code :

unsigned long long getMaxValue() {
    return -1;
}

Here is the JNI code :

extern "C"
JNIEXPORT jlong JNICALL
Java_com_tb_of_1ir_MainActivity_getMaxValue(JNIEnv *env, jobject thiz) {
    static auto a = MyCppSingleton::get();
    return a->getMaxValue();
}

And here is the Kotlin code :

Toast.makeText(this, "getMaxValue : \"${getMaxValue()}\"", Toast.LENGTH_LONG).show()
private external fun getMaxValue(): Long

I also tried with BigInteger but with no result…

Thanks !

Solution

It is not possible in a simple way. Maybe by decomposition.

Answered By – KotlinIsland

Answer Checked By – Laura B. (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published