I upload photo to the server via the default HttpClient in Android SDK. I want to show progress in the user interface, is there a way to find out how much has been uploaded? Is it possible with HttpUrlConnection?
I upload photo to the server via the default HttpClient in Android SDK. I want to show progress in the user interface, is there a way to find out how much has been uploaded? Is it possible with HttpUrlConnection?
Or you should use AsyncTask to do the actual process of file upload and use ProcessDialog to start and stop the process.
You can see this code, http://github.com/narup/mymobile/blob/master/pbdroid/src/com/example/android/skeletonapp/StoreListActivity.java i wrote to load the JSON data over HTTP and i use process dialog.
Main part of the code is :
private class LoadStoresTask extends AsyncTask<String, Void, List<Store>> {
@Override
protected List<Store> doInBackground(String... params) {
return WsiStoresClient.connect(params[0]);
}
@Override
protected void onPostExecute(List<Store> result) {
dismissDialog(BUSY_DIALOG_KEY);
}
}
I did not work with that API, but notice that HttpClient is not android specific:
org.apache.http.client.HttpClient
So if you google for "HttpClient progress" there is a number of posts that may be usefull.
Also, consider that post Android Download Progress