Search code examples
javaandroiddropbox

Unable to create link with DBX chooser error android


I am attempting to integrate the Dropbox chooser drop-in api into my application. I am running into an abnormal issue. In my app when I launch the dbx chooser, anytime that I select a file the application fails with the following error code:

Sorry, an error has occurred. Please try again later.

Here is the portion of my code that implements the Dropbox API. This portion of the code is where the dropbox api is initially invoked.

public void StartDropboxApplication() {
    // create the chooser
    DbxChooser chooser = new DbxChooser(APP_KEY);

    DbxChooser.ResultType result;

    // determine which mode to be in // TODO REMOVE ALL BUT FILE CONTENT TODO SIMPLIFY by making this a setting
    switch(( (RadioGroup) ParentActivity.findViewById(R.id.link_type)).getCheckedRadioButtonId() ) {
        case R.id.link_type_content:
            result = DbxChooser.ResultType.DIRECT_LINK;
            break;
        default:
            throw new RuntimeException("Radio Group Related error.");
        }

        // launch the new activity
        chooser.forResultType(result).launch(ParentActivity, 0);
    }

Here is the position where the code should then pick it up although it never does.

protected void onActivityResult( int request, int result, Intent data ) {
    Log.i(fileName, "result: " + result);

    // check to see if the camera took a picture
    if (request == 1) {
        // check to see if the picture was successfully taken
        if (result == Activity.RESULT_OK) {
            onPicture();
        } else {
            Log.i(fileName, "Camera App cancelled.");
        }
    } else if (request == 0) {
        if ( result == Activity.RESULT_OK ) {
            onDropbox(data);
        } else {
            Log.i(fileName, "dropbox related issue.");
        }
    }
}

Thank you for any help or suggestions that you are able to provide.


Solution

  • I was able to solve my own issues and get this working. On the off chance that someone else has a similar problem I will detail the solution. The first issue was I was that my APP_KEY was incorrect.

    The next issue was that I was attempting to read from a direct link instead of a content link. The direct link provides the application with a link to the file on the Dropbox server whereas the content link provides the application with a cached version of the file. If the file is not present on the device, the SDK downloads a copy for you.