Reputation: 558
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
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
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
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
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