Android Intent.ACTION_PICK closes Qt application



  • Hello,
    I want to add Intent.ACTION_PICK to my application and I did manage to do this.
    Problem that I'm having is that when external (in this case image) application is shown and application to browse images is chosen and launched, then Qt application dies.

    Running intent :
    java side

    public class Pix extends QtActivity
    {
        public static Intent pixPicker() {
            Intent i = new Intent( Intent.ACTION_PICK);
            i.setType( "image/*");
            return Intent.createChooser( i, "Select Image");
        }
    }
    

    Qt side:

        QAndroidJniObject intent = QAndroidJniObject::callStaticObjectMethod (
                                                    "com/example/Pix",
                                                    "pixPicker",
                                                    "()Landroid/content/Intent;"
                                                    );
        QtAndroid::startActivity( intent, 192837465, 0);
    

    Any idea why Qt application dies?



  • Update:
    I changed code completely, moved to Qt solution, with this:

    void MainWindow::onTest()
    {
        QAndroidJniObject action = QAndroidJniObject::fromString( "android.intent.action.PICK");
        QAndroidJniObject intent( "android/content/Intent");
    
        if (!action.isValid() || !intent.isValid()) {
            qDebug() << "Activity start error";
            return;
        }
    
        intent.callObjectMethod( "setAction", "(Ljava/lang/String;)Landroid/content/Intent;", action.object<jstring>());
        intent.callObjectMethod( "setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("image/*").object<jstring>());
        QtAndroid::startActivity( intent.object<jobject>(), 123456);
    }
    

    NOTE: omitted here third param with is handler for Intent

    But unfortunately exactly same issue occur, with is:

    1. run app - ok
    2. run Ui action to trigger above method - OK
    3. create Intent action PICK - OK
    4. show application chooser for mime - OK
    5. launch application to pick (in this case) image - OK
    6. Qt application dies at this point ...
    7. After image is chosen, using build in gallery application, qt application is relaunched.

    I tested this using test widget project with default manifest (that QtCreator creates if one is not specified).
    On device when clicking "Recent" button (while Gallery application, after Intent launch, is still running) I can see Gallery Application content and Qt application Icon with application name, so it seams like Gallery is launched as sub process of Qt application.

    Maybe I'm missing something? Like ignoring signal or handling susspend state / aditional entry in AndroidManifest.xlm?

    Because to me this behaviour is wrong, because now i.e. I can't retrieve image path because my application simply "resets" to it's default state.

    PS. debug output when above slot is executed:

    ...
    V/ContextImpl(15300): ----- packageName = android is NOT LOCKED -----
    I/AndroidRuntime(15300): VM exiting with result code 0, cleanup skipped.
    
    "org.qtproject.Sample" died.
    

    What does "----- packageName = android is NOT LOCKED -----" means?



  • UPDATE:
    I'm using ASUS device for testing. By default my device was "locked". It may be leftover implementation debug message that says that my device is simply unlocked - ASUS do check if device is locked or no and base on situation can void warranty (or voids it by default if unlocked - don't remember exactly - and my device is "unlocked" and rooted).

    Now about crash - tested on emulator - works flawlessly. On device app closes. I looked around and other person who uses ASUS device had similar problem so I think this is ASUS issue and changes that they introduced do interfere.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.