cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

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

New member | Level 1
New member | Level 1

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 6
Highlighted

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

Dropboxer
Dropboxer

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! 

Highlighted

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

New member | Level 1
New member | Level 1

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

Highlighted

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

Dropboxer
Dropboxer

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.

Highlighted

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

New member | Level 1
New member | Level 1

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

Highlighted

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

Dropboxer
Dropboxer

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

Highlighted

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

New member | Level 1
New member | Level 1

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

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?