realtime update

ProgressBar updating using Message Handler

SDK Version: 
M3

You're going to learn how to make a progressbar, which gives you a feedback what's going on in the background.

Let say you have a LoadingScreen activity (loadingscreen.xml layout), and a Main activity (main.xml).

You'd like to do some job in the Main activity, and update the progressbar status at the same time. To do this, we are going to use Messages. Although, you can update you're progressbar by sending the progressbar instance itself to your Main activity, but that's obviously not the prettiest solution.

What we going to do is:

1. Declaring a progressbar instance in LoadingScreen Activity:

So in your LoadingScreen.java, after Oncreate(), you should add something like this line to your codeline: (don't forget to add a progressbar to your layout first!)

  1.   ProgressBar pb = (ProgressBar)findViewById(R.id.ProgressBar01);

2. Setting up a Handler to handle Messages from outside:

Syndicate content