Exchanging data between Android Activity and Qt cpp
Unsolved
Mobile and Embedded
-
This is my native cpp function
void OnNFCState(jstring Value) { Environment->GetStringUTFChars(Value, nullptr); }
and this is the java side
private static native void OnNFCState(java.lang.String Value);
The app goes to crash at the line
Environment->GetStringUTFChars(Value, nullptr);
How can I have a QString from java.lang.String?
Is jstring corresponding to java.lang.String? -
@mrdebug said in Exchanging data between Android Activity and Qt cpp:
void OnNFCState(jstring Value) {
Environment->GetStringUTFChars(Value, nullptr);
}I know this post is old, but just see it today for the first time. To resolve your issue, simply use
QAndroidJniObject::toString()
, like this:void OnNFCState(jstring Value) { qDebug() << "Value is" << QAndroidJniObject(Value).toString(); }