cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AndroidAuthSession, DropboxException are not recognizable

AndroidAuthSession, DropboxException are not recognizable

rekte
Explorer | Level 3

Hello, I deleted the v1 dropbox sdk from my android app and added 3.0.4. The following things are not recognizable by android studio. Where can I check out what to use intead of (for example) AndroidAuthSession?

 

Thanks

AndroidAuthSession,
DropboxException
DropboxAPI

 

private AndroidAuthSession buildSession() throws DropboxException {
AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeyPair);

session.setOAuth2AccessToken(ACCESSTOKEN);
return session;
}
AndroidAuthSession session = null;
try {
session = buildSession();
} catch (DropboxException e) {
e.printStackTrace();
}
dropboxAPI = new DropboxAPI<>(session);
String[] fnames;
DropboxAPI.Entry dirent = null;
try {
dirent = dropboxAPI. metadata("/", 1000, null, true, null);
} catch (DropboxException e) {
e.printStackTrace();
}
ArrayList<DropboxAPI.Entry> files = new ArrayList<>();

 

1 Reply 1

Re: AndroidAuthSession, DropboxException are not recognizable

Greg-DB
Dropboxer

For Android, we recommend using the official Dropbox API v2 Java SDK:

 

https://github.com/dropbox/dropbox-sdk-java

 

It sounds like you've already installed that. It doesn't use the same classes/interface as the old version, so you'll need to update your code. There's an example Android app using it here:

 

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

 

For instance, your AndroidManifest.xml should be set up as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xm...

 

You start the flow by calling startOAuth2Authentication as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

You complete the flow by calling getOAuth2Token as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

Your app can store and re-use the resulting access token for that user, as the example does here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

You can find examples of calling getMetadata and listFolder here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/e707252998d14821b06e7e2a2b69a9c80d7b0829/examples/w...


https://github.com/dropbox/dropbox-sdk-java/blob/c6aeb4bf3011e6b803eaa325ea20a52f8412ee0f/examples/t...

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?