public class ListingFoundBeaconService
extends AsyncTask<String, String, String> {
public ListingFoundBeaconService(Context contextGiven,
JSONObject jsonParams) {
this.contextGiven = contextGiven;
this.jsonParams = jsonParams;
}
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(contextGiven);
pDialog.setMessage("Loading list of active Beacons..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
Log.d("onPreExecute","onPreExecute worked" );
}
protected String doInBackground(String... args) {}
protected void onPostExecute(String file_url) {
// Two activities will need this thread so I have
// kept this as a separate class. Here I want to send a
// boolean value to the parent activity to show that
// the task has completed or not.
}
Can I trigger a notification or complete event listener in onPostExecute() function so that the parent class which started this class(ListingFoundBeaconService) is notified? What is the standard way of doing it?
Best way is to call delegate. In your
AsyncTaskclass make a constructor and have a delegateDelegate interface:
now in
AsyncTask:on
postExecute:In your main class implement
TaskDelegateand implemented a method which is called when the task completed.