Try it, If you want to paas any specific message to UI
then use message object for the same.

like Message msg = handler.obtainMessage();e fucntion
// set any value
// get the same value in hadleMessag


Complete code is  here

ProgressBar bar;
Handler handler=new Handler() {
    public void handleMessage(Message msg) {
    bar.incrementProgressBy(5);
    }
 };

public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
bar=(ProgressBar)findViewById(R.id.progress);

bar.setProgress(0);

Thread background=new Thread(new Runnable() {
public void run() {
try {
for (int i=0;i<20 && isRunning;i++) {
Thread.sleep(1000);
handler.sendMessage(handler.obtainMessage());
}
}
catch (Throwable t) {
    // just end the background thread
}
}
}
}

- Anurag Singh


On Sun, Apr 25, 2010 at 12:38 PM, pramod.deore <[email protected]>wrote:

>
> Hello everybody again,
>
> Now my code runs in background anfd on foreground it shows progress
> bar.But now I want to show another screen after sendFileToServer
> method completes. I had tried followinfg but throws exception. Please
> help me how to to do this?
>
>  public void onClick(View v)
>    {
>        if (v==yesButton)
>                {
>                 setContentView(R.layout.main2);
>
>                t = new Thread(){
>                           public void run()
>                           {
>                                    while (!threadDone)
>                                   {
>                                           sendFileToServer();
>
>                                   }
>                                   setContentView(R.layout.main3);
>                           }
>                        };
>
>                        t.start();
>
>                }
>    }
>
>    public void sendFileToServer()
>    {
>        for (int i=0;i<5000;i++)
>        {
>
>                System.out.println ("Now value of i is"+i);
>        }
>         threadDone = true;
>
>
>    }
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Best Regards,
Anurag Singh

-- 
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

Reply via email to