Forum Discussion

Deepu R.'s avatar
Deepu R.
New member | Level 1
11 years ago

onActivityresult() not being invoked after choosing file using Dropbox Chooser

Hi,
I am trying to use the Dropbox Chooser Api in android app to allow the user to choose files from Dropbox. I was able to launch the Dropbox Chooser successfully from the android app, but after selecting the file, it shows "Creating link..." and then returns to the app. I've overridden onActivityresult() method to get the information about the selected file.But, unfortunately the onActivityresult() is not being invoked and I'm not able to get information about the selected file. I don't see any error in the log except for
"com.dropbox.android.service.DropboxNetworkReceiver(15150): Setting receiver enabled: false".
Kindly help me to resolve this issue.
Thanks in advance.

Regards,
Deepu

6 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    11 years ago

    Can you share:

    - the version number of the Android Chooser SDK you're using

    - the relevant code snippets

    - whether or not the example app included with the SDK works for you?

    Thanks in advance! 

  • Deepu R.'s avatar
    Deepu R.
    New member | Level 1
    11 years ago

    Hi Gregory,

    - The Android SDK version is 1.0.1.

    - Currently I'm trying to integrate Dropbox Chooser as a cordova plugin in to my app.

    So in the plugin java file indside execute() method I've added the following lines of code:-

    cordova.setActivityResultCallback(DropboxPlugin.this);
    mChooser = new DbxChooser(APP_KEY);
    mChooser.forResultType(DbxChooser.ResultType.PREVIEW_LINK)
    .launch(this.cordova.getActivity(), DBX_CHOOSER_REQUEST);

    And I've overridden onActivityresult() method.

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    System.out.println("------Inside onActivityResult ------");
    if (requestCode == DBX_CHOOSER_REQUEST) {
    if (resultCode == Activity.RESULT_OK) {
    DbxChooser.Result result = new DbxChooser.Result(data);
    String fileName = result.getName();
    }
    }
    else {
    super.onActivityResult(requestCode, resultCode, data);
    }

    }

    But now I can observe that for the first time, after launching the Dropbox Chooser and choosing a file, the onActivityResult() is never being invoked.
    From the second time onwards, the onActivityResult() method is getting invoked even before the Dropbox Chooser is launched.

    Please provide any inputs on this issue.

    Let me know if you want any further inputs from me.

    Thanks,
    Deepu

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    11 years ago

    Thanks! Does the sample app in the SDK work for you though? That might be a good indicator of whether or not Cordova is relevant to the issue.

  • Deepu R.'s avatar
    Deepu R.
    New member | Level 1
    11 years ago

    I can't test the sample app provided in the SDK, since the app I am currently developing is based on web view and I won't be able to use the sample java file provided. :-(

    Can you provide any other input.

    Thanks,

    Deepu

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    11 years ago

    The sample app included with the SDK is a working, standalone app that you can run by itself, unrelated to your own app.

    Anyway, Dropbox itself doesn't really control when onActivityResult gets called, since that's just part of the Android app lifecycle. I still suspect this is due to how Cordova works, so you may need to refer to the Cordova documentation. For example there's a StackOverflow question here that looks like it may be relevant:

    https://stackoverflow.com/questions/18125415/onactivityresult-never-gets-called-phonegap-cordova

  • Deepu R.'s avatar
    Deepu R.
    New member | Level 1
    11 years ago

    Yes!!Finally found the solution. I need to pass an instance of CordovaInterface to launch the Dropbox Chooser in order to get the result back to the plugin. Otherwise it will never get invoked.

    Thanks Gregory, for the inputs.

    Regards,

    Deepu

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!