Hi!
You probably want to use a Thread() to perform the dataupload, if it
is a big file that your are uploading a Service (bindService) might be
better since it will continue to run even if the activity is
destroy'ed . The following code till perform the data upload in a new
thread.
Thread t = new Thread() {
public void run() {
sendFileToServer();
}
}
t.start();
Note that in order to manipulate the UI from inside the thread the
method RunOnUIThread() must be used.
//Erik
On 24 Apr, 09:03, "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