[SOLVED] How can i call an other App from a Qt App for Androids?
-
Hello!!
I try to design an App with Qt , the Qt app reads a tcp connection for RTLSDR raw data and then demodulate the ADSB signal.
Because i cannot find a solution to read the usb device with libusb in Android i found a JAVA app from martin martinov, at this link https://play.google.com/store/apps/details?id=marto.rtl_tcp_andro&hl=en.
This App sends the raw data via TCP connection. So i have to start this App manually, but it is very troublesome for a user.
The developer of this App says that we can call a new intent from an other App behind the scenes.
All i need is to launch an intent in the formiqsrc://-f 1090000000 -s 200000 - a 127.0.0.1 -g 100
.How can i do that with QT ?
Thank you very much in advance !!
Also i need some testers so if you want send an invite to this group for more infos :https://groups.google.com/forum/#!forum/trackyourflight -
Use http://doc.qt.io/qt-5/qtandroid.html
Or use java + JNI. In android Qt examples you can find "NotificationClient" ( "Qt notifier" )
-
Use http://doc.qt.io/qt-5/qtandroid.html
Or use java + JNI. In android Qt examples you can find "NotificationClient" ( "Qt notifier" )
-
@jalomic said:
Use http://doc.qt.io/qt-5/qtandroid.html
Or use java + JNI. In android Qt examples you can find "NotificationClient" ( "Qt notifier" )
What is better ? SGaist has also a suggestion ?
@xmaze it amounts to the same thing
QAndroidJniObject - its nice JNI wrapper. For example QtAndroid ::androidActivity() - returns QAndroidJniObject, and you can call any method of your activity etc. =)
In "Qt notifier" Example you can see how to create your own main java activity. -
-
if i started ok then i need something like this
QtAndroid::startActivity("marto.rtl_tcp_andro.DeviceOpenActivity",0,0);
but i cannot understand where i have to put the command
"iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100"
Some help please ?@xmaze said:
iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100
For QtAndroid::startActivity you must create intent first !
QAndroidJniObject url=QAndroidJniObject::fromString("iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100"); QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("android/content/Intent","parseUri","(Ljava/lang/String;I)Landroid/content/Intent;", url.object<jstring>(),0x00000001); QtAndroid::startActivity(intent,code,receiver)
-
@xmaze said:
iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100
For QtAndroid::startActivity you must create intent first !
QAndroidJniObject url=QAndroidJniObject::fromString("iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100"); QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("android/content/Intent","parseUri","(Ljava/lang/String;I)Landroid/content/Intent;", url.object<jstring>(),0x00000001); QtAndroid::startActivity(intent,code,receiver)
-
Oh my Got, Thank you very much!! This is very complicated, i couldn't find it, never!!
-
Oh my Got, Thank you very much!! This is very complicated, i couldn't find it, never!!
-
@xmaze =) There is an much easier way
QDesktopServices::openUrl((QUrl("iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100"))or just from QML
onClicked: Qt.openUrlExternally(iqsrc://-f 1090000000 -s 2000000 - a 127.0.0.1 -g 100")
-
@xmaze And it is very interesting for me. Does it work startActivity as i showed befor ? I have no chance to check it
QAndroidJniObject url=QAndroidJniObject::fromString("iqsrc://-f 1090000000 -p 5000 -s 2000000 -a 127.0.0.1 -g 100"); QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("marto/rtl_tcp_andro/DeviceOpenActivity","parseUri","(Ljava/lang/String;I)Lmarto/rtl_tcp_andro/DeviceOpenActivity;", url.object<jstring>(),0x00000001); QtAndroid::startActivity(intent,0,0);
I tried this code but i have a black screen, i call this in Constructor of the QMainWindow, i am not sure if i call right the Application, i am not sure about the
marto/rtl_tcp_andro/DeviceOpenActivity -
QAndroidJniObject url=QAndroidJniObject::fromString("iqsrc://-f 1090000000 -p 5000 -s 2000000 -a 127.0.0.1 -g 100"); QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("marto/rtl_tcp_andro/DeviceOpenActivity","parseUri","(Ljava/lang/String;I)Lmarto/rtl_tcp_andro/DeviceOpenActivity;", url.object<jstring>(),0x00000001); QtAndroid::startActivity(intent,0,0);
I tried this code but i have a black screen, i call this in Constructor of the QMainWindow, i am not sure if i call right the Application, i am not sure about the
marto/rtl_tcp_andro/DeviceOpenActivity -
QAndroidJniObject url=QAndroidJniObject::fromString("iqsrc://-f 1090000000 -p 5000 -s 2000000 -a 127.0.0.1 -g 100"); QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("marto/rtl_tcp_andro/DeviceOpenActivity","parseUri","(Ljava/lang/String;I)Lmarto/rtl_tcp_andro/DeviceOpenActivity;", url.object<jstring>(),0x00000001); QtAndroid::startActivity(intent,0,0);
I tried this code but i have a black screen, i call this in Constructor of the QMainWindow, i am not sure if i call right the Application, i am not sure about the
marto/rtl_tcp_andro/DeviceOpenActivity -
@jalomic code and receiver is not something, i change this to null.
ok, it calls the other app but how can i wait for the other app to complete the intialitation before to process the qt app. I am not sure also if all the arguments are right, i have to make some tests and i write the results the next hours!
thanks -
Thank you it's working!!
I made a workaround, i put a sleep() function for 4 seconds to wait until the other App is started!!