Below is my code for uploading a file to the server. But I\'m getting network exceptions even after several tries and even after adding strict mode.
I\'m new to Andr
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new UploadImageTask().execute(); // initialize asynchronous task
}});
//Now implement Asynchronous Task
public class Get_User_Data extends AsyncTask {
private final ProgressDialog dialog = new ProgressDialog(
MyActivity.this);
protected void onPreExecute() {
this.dialog.setMessage("Loading...");
this.dialog.setCancelable(false);
this.dialog.show();
}
@Override
protected Void doInBackground(Void... params) {
uploadImage(); // inside the method paste your file uploading code
return null;
}
protected void onPostExecute(Void result) {
// Here if you wish to do future process for ex. move to another activity do here
if (dialog.isShowing()) {
dialog.dismiss();
}
}
}
For more information refer this link http://vikaskanani.wordpress.com/2011/01/29/android-image-upload-activity/