Back to project page Bussan.
The source code is released under:
Copyright 2011 Kristian Bendiksen. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project Bussan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package no.kriben.bussan; /*from w w w .j a v a 2 s . c o m*/ import android.app.Activity; import android.os.AsyncTask; // Async task which connects to an application instance. // Code adapted from // http://www.fattybeagle.com/2011/02/15/android-asynctasks-during-a-screen-rotation-part-ii/ // public abstract class BussanAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> { protected BussanApplication application_; protected Activity activity_; public BussanAsyncTask(Activity activity) { activity_ = activity; application_ = (BussanApplication) activity_.getApplication(); } public void setActivity(Activity activity) { activity_ = activity; if (activity_ == null) { onActivityDetached(); } else { onActivityAttached(); } } protected void onActivityAttached() {} protected void onActivityDetached() {} @Override protected void onPreExecute() { application_.addTask(activity_, this); } @Override protected void onPostExecute(Result result) { application_.removeTask(this); } @Override protected void onCancelled() { application_.removeTask(this); } }