My app uploads an image to the server. In order to execute an uploading, I use the HttpPost
class. Here is the relevant code fragment:
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("%PATH_TO_SERVER_PAGE%");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
} catch (Exception e) {
System.out.println("Connection error: " + e.toString());
}
How can I raise an event and know if the uploading has been successfully finished to be sure that the file is already on a server?
Probably, the implementation of the Observer Design Pattern would be a suitable solution.
Reference: https://stackoverflow.com/a/6270150/462347