Run Intent for Qt Android app



  • Hello. I design android application for use rtl dongle. 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

    Use this driver with java:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setClassName("marto.rtl_tcp_andro", "com.sdrtouch.rtlsdr.DeviceOpenActivity");
    intent.setData(Uri.parse("iqsrc://-a 127.0.0.1 -p 1234 -n 1"));
    startActivityForResult(intent, RTL2832U_RESULT_CODE);
    

    So, i write this in Qt C++:

    QAndroidJniObject url = QAndroidJniObject::fromString("iqsrc://-a 127.0.0.1 -p 1234 -n 1 -f 100000000 -s 1024000");
    if(url.isValid())
    {
        QAndroidJniObject intent=QAndroidJniObject::callStaticObjectMethod("marto/rtl_tcp_andro/DeviceOpenActivity","parseUri","(Ljava/lang/String;I)Lmarto/rtl_tcp_andro/DeviceOpenActivity;", url.object<jstring>(),0x00000001);
    
        if(intent.isValid())
        {
            QtAndroid::startActivity(intent, RTL2832U_RESULT_CODE, this);
            qDebug() << ("QtAndroid::startActivity receiverRequestCode: " + QString::number(RTL2832U_RESULT_CODE));
        }
        else
        {
            qDebug() << "invalid QAndroidJniObject intent";
        }
    }
    else
    {
           qDebug() << "invalid QAndroidJniObject url";
    }
    

    And, this not work - object intent is not valid. In my console - "invalid QAndroidJniObject intent";
    Who can help me?



  • @Vitaliy Are you sure you have the class and function signature correct?

    Maybe run in a debugger and step into the QAndroidJniObject creation and see why it might be failing.


Log in to reply