import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class AsyncTasks extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button upload = (Button) findViewById(R.id.widget27);
upload.setOnClickListener(new OnClickListener() {
public void onClick(View pV) {
new DoInBackground().execute();
}
});
}
public void do_update() {
// your stuff here
Log.i("MSG", "msg");
}
private class DoInBackground extends AsyncTask<Void, Void, Void> implements
DialogInterface.OnCancelListener {
private ProgressDialog dialog;
protected void onPreExecute() {
dialog = ProgressDialog.show(AsyncTasks.this, "", "Busy...", true, true,
this);
}
protected Void doInBackground(Void... v) {
do_update();
return null;
}
protected void onPostExecute(Void v) {
dialog.dismiss();
}
public void onCancel(DialogInterface dialog) {
cancel(true);
dialog.dismiss();
}
}
}
Friday, July 15, 2011
Async Task in Android
By Magesh Kumar
Posted at 9:41 PM
Android
No comments
About the Author
Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9
- Draw 9-patch Tutorial
- Cracking apk to get java code
- Handling Button clicks in a ListView Row
- Android Menu and Submenu Example
- Larry Page: Android powers Google Glass
- Android GPS How to calculate the distance between two GPS coordinates?
- SlidingDrawer
- Gradient dividers in Android
- Thread Concepts:
- How to Crack a Software
Popular Posts
Total Pageviews
Powered by Blogger.
Contributors
About Me
Trending Stories
- Android (72)
- Blackberry (1)
- CSS (6)
- How to Crack a Software (1)
- HTML (14)
- Java (1)
- Java Scripts (6)
- Photoshop (11)
0 comments: