Uploading File To Dropbox In Android, Putfile Method Throws Exception
I'm trying to upload a file to Dropbox using the Dropbox API tutorial. I logged in when creating the Activity and I add some code to the onResume() method as said in the tutorial.
Solution 1:
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 putFile
method makes a network call to the Dropbox API servers to send up the file content.) You should make this call on a background thread instead. There are other answers about how to do this, e.g.: How to fix android.os.NetworkOnMainThreadException?
Solution 2:
Ok, thanks a lot Greg. It worked perfectly following the indications in the link you shared. I used another class extending AsyncTask, just like it's done in this post, the "Upload File to Dropbox using Android SDK" section.
Post a Comment for "Uploading File To Dropbox In Android, Putfile Method Throws Exception"