Android - I want to show file upload progress to the user

前端 未结 7 605
一向
一向 2020-12-07 14:51

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?

7条回答
  •  误落风尘
    2020-12-07 15:26

    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> {
    
    @Override
    protected List doInBackground(String... params) {
    return WsiStoresClient.connect(params[0]);
    }
    
    @Override
    protected void onPostExecute(List result) {
    dismissDialog(BUSY_DIALOG_KEY);
    }
    
    }
    

提交回复
热议问题