Int Conversion

There is a function in Java, that calls a native function with string argument, like setContentView("Hello World!"); and it works perfectly. Now repeat the same thing with integer: Java code: setContentView(2130903040); Native code:
"natives": {
Java_path_to_setContentView(lib, id) {
console.log(id);
}
}
"natives": {
Java_path_to_setContentView(lib, id) {
console.log(id);
}
}
And instead of number, id is some strange object (see screenshot).
No description
7 Replies
apignotti
apignotti12mo ago
What is the full signature of the native function? Also, please clarify which version of CheerpJ you are using. Is still the stable 3.0?
Новогодний кАшАчОк 😺🎄
Hello! Thanks for your answer, Using <script src="https://cjrtnc.leaningtech.com/3.0/cj3loader.js"></script> I don't really know what is a "signature" of the function, did you mean this? public static native void setContentView(int id); Sorry, found the error!
apignotti
apignotti12mo ago
static
Новогодний кАшАчОк 😺🎄
Yeah, that's the problem Static was not required here
Новогодний кАшАчОк 😺🎄
After removing it, got right int :)
No description
apignotti
apignotti12mo ago
You can use static too, but you need to be consistent. Without static there is an extra this argument first I think that the actual problem is that your .class or .jar file was not updated after changing the .java file. So he method was not actually static and you were observing the this object
Новогодний кАшАчОк 😺🎄
Yeah, right, .jar is compiled with different library Than the actual library that is used I'm just, Running .apk files Extracting .jar from apk's classes.dex That is already compiled by android studio

Did you find this page helpful?