Skip to content Skip to sidebar Skip to footer

Android - On Post Execute In Asynctask

I currently have an asyncTask which on preexecute begins a loading bar, in background send something to a server, and on post execute dismisses the dialog and enables a button. How

Solution 1:

It is completely Ok to return null from doInBackground() in your case. Just make sure onPostExecute() looks like this:

@OverrideprotectedvoidonPostExecute(Void result) {
    Log.d(TAG, "p execute");
    dialog.dismiss();
    sendButton.setEnabled(true);
    Log.d(TAG, "done executing");
}

Solution 2:

change your DatabaseAsync class like this:

classDatabaseAsyncextendsAsyncTask<String, Void, String>{

        protectedvoidonPreExecute(){
              dialog = ProgressDialog.show(MainFeedActivity.this, null, "Posting...");
        }


        protectedStringdoInBackground(String... arg0) {
            Log.d("TAG", "send to databse");

            Log.d("", "sent to database - DONE");


            //dialog.dismiss();//sendButton.setEnabled(true);returnnull;
        }

        protectedvoidonPostExecute(String result){
            Log.d("TAG", "p execute");
            dialog.dismiss();

            Log.d("TAG", "done executing");
        }

read this link after the code works http://www.vogella.de/articles/AndroidPerformance/article.html

Post a Comment for "Android - On Post Execute In Asynctask"