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

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

Android API get account email

New member | Level 2
New member | Level 2

I am not able to get the user account email after the authentication:

 

I have this code (in Kotlin) on my onResume

mDBApi!!.session.finishAuthentication()
val accessToken = mDBApi!!.session.oAuth2AccessToken
val client = DbxClientV2(DbxRequestConfig.newBuilder("dropbox/MyAppName").build(), accessToken)
val email = client.users().currentAccount.email

but the getCurrentAccount() throws me 'android.os.NetworkOnMainThreadException'.

How can I solve this to get the user account email?

1 Reply 1
Highlighted

Re: Android API get account email

Dropboxer
Dropboxer
You're getting a NetworkOnMainThreadException, which means you're trying to make a network call on the main thread, which isn't allowed on Android. (The Dropbox API methods each make a network call to the Dropbox API servers.) You should make this call on a background thread instead. This isn't specific to Dropbox, so there are several answers about how to do this on StackOverflow, e.g.:

https://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception

There's also an example of doing this in the Android sample app included with the Dropbox API v2 Java SDK:

https://github.com/dropbox/dropbox-sdk-java/blob/7ecc15cf0f51d6ae2ba5cdb334aac2c2f3474b87/examples/a...
Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

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?