Aaron Decker
Aaron Decker

Reputation: 558

Downloading large file from FTP server on Android causes a prompt for "Force Close" or "Wait"

I have an app that downloads a file from an FTP server upon tapping the file in a listview. Once the tap is received the download starts. This causes my app to become unresponsive, in logcat it is giving me the debugging info from the server and it is downloading just fine, the issue is this. If the download takes too long say over a minute or so android thinks the application is froze and asks if the user wants to Force Close or Wait. How do I prevent this?

Upvotes: 0

Views: 967

Answers (4)

andrefy
andrefy

Reputation: 81

yeah, you should use a different thread to download the file, I would use something like a loading dialog while the file is been uploading,

Upvotes: 0

TheGuyNextDoor
TheGuyNextDoor

Reputation: 7937

Use worker threads, refer to Handling Expensive Operations in the UI Thread, http://developer.android.com/guide/appendix/faq/commontasks.html#threading

Upvotes: 1

Scott M.
Scott M.

Reputation: 7347

since the download is taking so long the UI thread is doing nothing. Android assumes your program is stuck and offers to kill it since it isn't making any "progress." Use another thread to download anything.

Upvotes: 1

EboMike
EboMike

Reputation: 77722

Everything that takes even a small amount of time needs to happen in a worker thread. Methods in the main thread need to return as quickly as possible, or else your app will become unresponsive.

Upvotes: 0

Related Questions