0

Now, i would like to call this drivers from my App, but i use QT. I found the classes QAndroidJNIObject to call java code. I found also at github.com/demantz/RFAnalyzer/blob/master/app/src/main/java/com/mantz_it/rfanalyzer/MainActivity.java an example in java.

try { 
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("iqsrc://-a 127.0.0.1 -p 1234 -n 1"));
    startActivityForResult(intent, RTL2832U_RESULT_CODE); 
}
catch (ActivityNotFoundException e) 
{
    Log.e(LOGTAG, "createSource: RTL2832U is not installed");
    ...
}

But i cannot find a way to write the right code in C++/Qt to make the equal call like the example in Java. I am not sure if this java code is correct or missing something.

Can someone help me ?

Also i want to ask if i can have a tcp connection with anet.h libs from Qt code?

4

1 回答 1

0

您需要使用QJniAndroidObject类来创建 JNI 对象并对其进行操作。这并不总是显而易见的,但它最终会起作用。您的 9 行 Java 很可能最终成为 50 行 C++ 代码。我建议您逐行转码并始终检查对象是否有效(QJniAndroidObject::isValid())。

这是一个创建Intent和启动活动的示例: Qt 上的 startActivity,没有显示

如果失败,请尝试编写一些代码并发布另一个 SO 问题(QJniAndroidObject对于不熟悉 Java 的 C++ 开发人员来说,创建和操作的语法并不总是显而易见的)。

于 2015-12-26T07:47:34.313 回答