0

I programmed my first app today with this tutorial http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

In addition I added an FTP Upload for a File from SD Card to my own FTP, which is working also well. With on exception. I'm getting the (translated) error "Application is not responding, WAIT or CLOSE" (https://imgur.com/C2pLaiO) because the file which I am uploading is about 30MB so that it needs some time.

For the ftp Upload I used the library ftp4j-1.7.2.jar from sauronsoftware.it/projects/ftp4j/

What do I need to do to get rid of this message?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

It sounds like you are doing this file transfer on the UI Thread and since it takes some time, it is causing your application to hault until it is finished. You can put that code in an AsyncTask. This will help in a couple ways

  1. It can do the file transfer on a background Thread while allowing not holding up your UI and giving you this ugly message
  2. AsyncTask has built-in methods which allow you to do operations on the ui such as showing a ProgressDialog/ProgressBar

You would put your "heavy-lifting" code in doInBackground() and your ui stuff (showing/dismissing progress) in onPreExecute()/onPostExecute() and you can do things such as update a ProgressBar by calling publishProgress() in doInBackground() which will call onProgressUpdate().

See this answer for an example of AsyncTask

AsyncTask Docs

Community
  • 1
  • 1
codeMagic
  • 44,549
  • 13
  • 77
  • 93
0

I would recommend you use an AsyncTask to upload the file, as it doesnt stop the UI from running while the upload occurs (hence, no "Application is not responding" will be shown).

cavpollo
  • 4,071
  • 2
  • 40
  • 64