Your sendFileToServer function should be in a separate thread, like the background operation of an AsyncTask.
Your android application is doing everything in the main thread, the UI thread, so it is doing your "file send", then, when it comes back, it is updating the UI. On Apr 24, 1:03 am, "pramod.deore" <[email protected]> wrote: > Hello everybody, > I am developing one application in that I am using progress > bar. but progress bar is display after task is completed.but I want to > run progress bar first and task must be completing in background. Here > is my code > > import android.app.Activity; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > > public class Progress extends Activity implements OnClickListener > { > Button yesButton,noButton; > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > setContentView(R.layout.main1); > yesButton = (Button) findViewById(R.id.widget31); > noButton = (Button) findViewById(R.id.widget32); > > yesButton.setOnClickListener(this); > noButton.setOnClickListener(this); > } > > public void onClick(View v) > { > if (v==yesButton) > { > setContentView(R.layout.main3); > sendFileToServer(); > } > } > > public void sendFileToServer() > { > for (int i=0;i<5000;i++) > { > System.out.println ("Now value of i is"+i); > } > } > > } > > Here it prints value of i from 0 to 4999 then after that > R.layout.main3 is displayed. > what should I have to do? should I have to create a class that extends > from Service class in that palced the method sendFileToServer > > Please help me. > > Thanks > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

