How to display a progress bar for 1 minute? - android

I have a horizontal progress bar in android. I need to make it complete in 60 seconds.
Why doesn't the below code work?
int progress = 0;
progressBarHorizontal.setMax(60);
while(progress < 60) {
progressHandler.postDelayed((new Runnable() {
public void run() {
progressBarHorizontal.setProgress(progress);
}
}),progress * 1000);
progress++;
}
Please suggest some other methods. I tried this:
new Thread(new Runnable() {
int progress = 0;
public void run() {
long timerEnd = System.currentTimeMillis() + 60 * 1000;
while (timerEnd > System.currentTimeMillis() ) {
progress = (int) (timerEnd - System.currentTimeMillis()) / 1000;
// Update the progress bar
progressHandler.post(new Runnable() {
public void run() {
progressBarHorizontal.setProgress(progress);
}
});
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Log.w("tag","Progress thread cannot sleep");
}
}
}
}).start();
But it is not working either.
The second piece of code actually works, the problem was with my logic.

you can try the CountDownTimer :
pd = ProgressDialog.show(MovementEntry.this, "", "Please Wait...",
true, false);
pd.show();
new CountDownTimer(60000, 1000) {
#Override
public void onTick(long millisUntilFinished) {
//this will be done every 1000 milliseconds ( 1 seconds )
int progress = (60000 - millisUntilFinished) / 1000;
pd.setProgress(progress);
}
#Override
public void onFinish() {
//the progressBar will be invisible after 60 000 miliseconds ( 1 minute)
pd.dismiss();
}
}.start();

This one will update the statusbar until it reaches its maximum value:
private int progress = 0;
private final int pBarMax = 60;
...
final ProgressBar pBar = (ProgressBar) findViewById(R.id.progressBar1);
pBar.setMax(pBarMax);
final Thread pBarThread = new Thread() {
#Override
public void run() {
try {
while(progress<=pBarMax) {
pBar.setProgress(progress);
sleep(1000);
++progress;
}
}
catch(InterruptedException e) {
}
}
};
pBarThread.start();

You can try this code for that:
Thread timer = new Thread(){
public void run(){
try{
sleep(10000);
while(progressBarStatus < 10000){
StartPoint.this.runOnUIThread(new Runnable(){
public void run()
{
progressBar.setProgress(progressBarStatus);
progressBarStatus += 1000;
}
});
}
}catch(InterruptedException e){
e.printStackTrace();
}finally{
}
}
};
timer.start();

This code works for me
new Thread(new Runnable() {
public void run() {
long timerEnd = System.currentTimeMillis() + 60 * 1000;
while (timerEnd > System.currentTimeMillis()) {
progress = 60 - (int) (timerEnd - System.currentTimeMillis()) / 1000;
// Update the progress bar
progressHandler.post(new Runnable() {
public void run() {
progressBarHorizontal.setProgress(progress);
}
});
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Log.w("App","Progress thread cannot sleep");
}
}
progressHandler.post(new Runnable() {
public void run() {
okButton.performClick();
}
});
}
}).start();

Related

Implementing a progress bar in android with specific values doesn't work

I tried to implement a layout that works like a progress bar. I want to it to be able to be set to any level I want in special cases. For example to be set to 20.
#Override
public void handleMessage(Message msg) {
if (msg.what == 0x123) {
mCDrawable.setLevel(mProgress);
}
}
Runnable a= new Runnable() {
#Override
public void run() {
running = true;
handler.sendEmptyMessage(0x123);
mProgress = 20;
try {
Thread.sleep(18);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
public void add(int num){
Thread s = new Thread(a);
s.start();
}
I do it by calling the "add" function.
The problem is that in a "while" where the progress changes continueslly it works:
Runnable r = new Runnable() {
#Override
public void run() {
running = true;
while (running) {
handler.sendEmptyMessage(0x123);
if (mProgress > MAX_PROGRESS) {
mProgress = 0;
}
mProgress += 100;
try {
Thread.sleep(18);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
What is the difference? How can I set it to a specific value otherwise?
---edit----:
I tried this code and it still doesnt work:
public void add(int num){
int lvl = mClipDrawable.getLevel();
Log.d("______________", "the first was "+lvl);
lvl += 100;
if (lvl > 10000) {
lvl = 1000;
}
Log.d("______________", "set to "+lvl);
mClipDrawable.setLevel(lvl);
}
the first level was 0 and it set 100..

why thread don't work accurately (a count down with thread)

I need count down timer that whenever I clicked or times up, send result and time score to another activity. So I used thread, but I don't know why in first time run activity it don't show time for some seconds in textview, one more strange thing is that when press back,then go to activity again it works fine.
count down code:
if (flagTime) {
flagTime = false;
new Thread(new Runnable() {
#Override
public void run() {
int counter = 60;
while (function.isActivityVisible() && counter > 0) {
counter--;
final int finalCounter = counter;
try {
Thread.sleep(1000);
G.HANDLER.post(new Runnable() {
#Override
public void run() {
if (function.isActivityVisible()) {
timeSc=finalCounter;
String preSec = "";
if (finalCounter < 10) {
preSec = "0";
}
if (function.isActivityVisible()
&& finalCounter <= 0) {
flagTime = false;
Intent intent = new Intent(
Memorize.this,
MemorizeResult.class);
intent.putExtra("TIME", 60);
intent.putExtra("ARRAY_RESULT",
array_choice);
startActivity(intent);
finish();
}
String score = "00:" + preSec
+ finalCounter;
txt[20].setText( " time ramaining " + score);
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
if (!function.isActivityVisible()) {
flagTime = false;
finish();
}
}
}).start();
}
I use many flag to handle it, but it seems don't work properly.
Try using a CountDownTimer
Something like:
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();

how to pause progressbar in android

I have made a progressbar in android,Which is horizontal,i want to freeze it when any button click in my activity,I have tried as below,But progress still displays.my code is as below:I want to do something like one question loaded after another,and onClick of any button counter and progress state should be stop,but rite now my timer stop but progress still ran up..it not stops.
code
public class QuestionAnswerActivity extends Activity implements OnClickListener {
// visible gone
ArrayList<HashMap<String, String>> QuestionList;
private int progressStatus = 0;
private Handler handler = new Handler();
Intent i;
private boolean run = true;
/**
* Answer [1=true / 0 =false]
*/
int myans;
String ans;
ProgressDialog pDialog;
TextView text_player_one;
String JsonStr;
ArrayList<HashMap<String, String>> questionList;
ImageView player_one_pic;
int count;
private DisplayImageOptions options;
public static ImageLoader imageLoader;
ImageView answer_right_one;
ProgressBar pg_loading;
private CountDownTimer countDownTimer;
TextView timer_text;
private final long startTime = 8 * 1000;
private final long interval = 1 * 1000;
Button opt_1, opt_2, opt_3, opt_4;
Thread splashThread;
TextView answer_question;
LinearLayout answer_linear_3;
// Response variables...!!
// Single player*************************************
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.question_answer_activity);
init();
}
// ***********************************************************************************************
/**
* Initialise the views
*/
#SuppressWarnings({ "deprecation", "unchecked" })
private void init() {
answer_linear_3 = (LinearLayout) findViewById(R.id.answer_linear_3);
answer_linear_3.setVisibility(View.GONE);
questionList = new ArrayList<HashMap<String, String>>();
answer_question = (TextView) findViewById(R.id.answer_question);
player_one_pic = (ImageView) findViewById(R.id.player_one_pic);
text_player_one = (TextView) findViewById(R.id.text_player_one);
text_player_one.setText(Pref.getValue(QuestionAnswerActivity.this,
Const.PREF_NAME, ""));
pg_loading = (ProgressBar) findViewById(R.id.pg_loading_answer);
timer_text = (TextView) findViewById(R.id.timer_text_loading11);
answer_right_one = (ImageView) findViewById(R.id.answer_right_one);
imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration
.createDefault(QuestionAnswerActivity.this));
options = new DisplayImageOptions.Builder().cacheOnDisc(true)
.displayer(new RoundedBitmapDisplayer((int) 3.5f))
.showStubImage(R.drawable.ic_launcher)
.showImageOnFail(R.drawable.ic_launcher).build();
imageLoader.displayImage(Pref.getValue(QuestionAnswerActivity.this,
Const.PREF_PROFILE_PIC, ""), player_one_pic, options);
opt_1 = (Button) findViewById(R.id.option_1);
opt_2 = (Button) findViewById(R.id.option_2);
opt_3 = (Button) findViewById(R.id.option_3);
opt_4 = (Button) findViewById(R.id.option_4);
count = 0;
questionList = (ArrayList<HashMap<String, String>>) getIntent()
.getSerializableExtra("queList");
System.out.println("::::::::My questions::::::::;+++++++"
+ questionList);
/*
* answer_question.setText(questionList.get(count).get("q_title"));
* opt_1.setText(questionList.get(count).get("opt1"));
* opt_2.setText(questionList.get(count).get("opt2"));
* opt_3.setText(questionList.get(count).get("opt3"));
* opt_4.setText(questionList.get(count).get("ans"));
*/
handler.postDelayed(new ViewUpdater(answer_linear_3), 1000);
answer_question.setText(questionList.get(count).get("q_title"));
opt_1.setText(questionList.get(count).get("opt1"));
opt_2.setText(questionList.get(count).get("opt2"));
opt_3.setText(questionList.get(count).get("opt3"));
opt_4.setText(questionList.get(count).get("ans"));
opt_1.setOnClickListener(this);
opt_2.setOnClickListener(this);
opt_3.setOnClickListener(this);
opt_4.setOnClickListener(this);
countDownTimer = new MyCountDownTimer(startTime, interval);
/*
* Initialise NoResponse Timer
*/
timer_text.setText(timer_text.getText()
+ String.valueOf(startTime / 1000));
countDownTimer.start();
new Thread(new Runnable() {
public void run() {
while (progressStatus < 100) {
progressStatus += 1;
// Update the progress bar and display the
// current value in the text view
handler.post(new Runnable() {
public void run() {
if (run) {
pg_loading.setProgress(progressStatus);
pg_loading.setProgressDrawable(getResources()
.getDrawable(R.drawable.progress));
}
}
});
try {
// Sleep for 200 milliseconds.
// Just to display the progress slowly
Thread.sleep(62);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
// ***********************************************************************************************
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
run = false;
switch (v.getId()) {
case R.id.option_1:
if (count <= 7) {
count++;
progressStatus = pg_loading.getProgress();
/* questionTask(count); */
new LeaveResponse()
.execute(questionList.get(count).get("q_id"));
}
break;
case R.id.option_2:
if (count <= 7) {
count++;
progressStatus = pg_loading.getProgress();
new LeaveResponse()
.execute(questionList.get(count).get("q_id"));
}
break;
case R.id.option_3:
if (count <= 7) {
count++;
progressStatus = pg_loading.getProgress();
new LeaveResponse()
.execute(questionList.get(count).get("q_id"));
}
break;
case R.id.option_4:
if (count <= 7) {
count++;
progressStatus = pg_loading.getProgress();
new LeaveResponse()
.execute(questionList.get(count).get("q_id"));
}
/*
* answer_question.setText(QuestionList.get(count).get("q_title"));
* opt_1.setText(QuestionList.get(count).get("opt1"));
* opt_2.setText(QuestionList.get(count).get("opt2"));
* opt_3.setText(QuestionList.get(count).get("opt3"));
* opt_4.setText(QuestionList.get(count).get("ans"));
* timer_text.setText(timer_text.getText() +
* String.valueOf(startTime / 1000));
*
* countDownTimer.start();
* answer_right_one.setVisibility(View.VISIBLE);
* pg_loading.setVisibility(View.GONE); countDownTimer.cancel();
*
* Toast.makeText(QuestionAnswerActivity.this,
* timer_text.getText().toString(), 1).show();
*/
break;
}
}
// ***********************************************************************************************
/**
* CountDown Timer for Starting No response activity if user doesnt
* responds.
*/
public class MyCountDownTimer extends CountDownTimer {
public MyCountDownTimer(long startTime, long interval) {
super(startTime, interval);
}
public void onpause() {
// TODO Auto-generated method stub
Toast.makeText(QuestionAnswerActivity.this, "Clicked", 1).show();
}
#Override
public void onFinish() {
Toast.makeText(getApplicationContext(), "onFinish",
Toast.LENGTH_SHORT).show();
/*
* If finish , that is user not responding , go to NoResponse
* screen.
*/
Intent intent = null;
intent = new Intent(QuestionAnswerActivity.this,
NoResponseActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
finish();
}
#Override
public void onTick(long millisUntilFinished) {
timer_text.setText("" + millisUntilFinished / 1000);
}
}
#SuppressWarnings("deprecation")
#SuppressLint("NewApi")
void questionTask(int count) throws InterruptedException {
if (count < 8) {
answer_linear_3.setVisibility(View.GONE);
answer_question.setText(questionList.get(count).get("q_title"));
handler.postDelayed(new ViewUpdater(answer_linear_3), 100);
myans = randomGenerator();
System.out.println(":::::::::::::;randomized answer::::::::::::;;;"
+ myans);
if (myans == 1) {
opt_1.setBackgroundDrawable(getResources().getDrawable(
R.drawable.true_selector));
opt_1.setText(questionList.get(count).get("ans"));
opt_2.setText(questionList.get(count).get("opt2"));
opt_3.setText(questionList.get(count).get("opt3"));
opt_4.setText(questionList.get(count).get("opt1"));
} else if (myans == 2) {
opt_2.setBackgroundDrawable(getResources().getDrawable(
R.drawable.true_selector));
opt_1.setText(questionList.get(count).get("opt2"));
opt_2.setText(questionList.get(count).get("ans"));
opt_3.setText(questionList.get(count).get("opt3"));
opt_4.setText(questionList.get(count).get("ans"));
} else if (myans == 3) {
opt_3.setBackgroundDrawable(getResources().getDrawable(
R.drawable.true_selector));
opt_1.setText(questionList.get(count).get("opt1"));
opt_2.setText(questionList.get(count).get("opt2"));
opt_3.setText(questionList.get(count).get("ans"));
opt_4.setText(questionList.get(count).get("opt3"));
} else {
opt_4.setBackgroundDrawable(getResources().getDrawable(
R.drawable.true_selector));
opt_1.setText(questionList.get(count).get("opt1"));
opt_2.setText(questionList.get(count).get("opt2"));
opt_3.setText(questionList.get(count).get("opt3"));
opt_4.setText(questionList.get(count).get("ans"));
}
countDownTimer = new MyCountDownTimer(startTime, interval);
/*
* Initialise NoResponse Timer
*/
timer_text.setText(timer_text.getText()
+ String.valueOf(startTime / 1000));
countDownTimer.start();
}
}
private class ViewUpdater implements Runnable {
private LinearLayout mView;
public ViewUpdater(LinearLayout linView) {
mView = linView;
}
#Override
public void run() {
mView.setVisibility(View.VISIBLE);
}
}
// Answer webservice call..!
private class LeaveResponse extends AsyncTask<String, String, Void> {
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
countDownTimer.cancel();
pDialog = new ProgressDialog(QuestionAnswerActivity.this);
pDialog.setMessage("Loading...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(String... params) {
// TODO Auto-generated method stub
BackendAPIService sh = new BackendAPIService();
String ResponseURL = Const.API_RESPONSE
+ "?os=droid&user_id="
+ Pref.getValue(QuestionAnswerActivity.this,
Const.PREF_USER_ID, "") + "&myrole="
+ Const.MY_ROLL + "&q_id=" + params[0] + "&ans=" + ans
+ "&time=5&game_id=" + Const.GAME_ID + "";
JsonStr = sh.makeServiceCall(ResponseURL, BackendAPIService.GET);
System.out.println("::::::::::::;My Response request::::::::::;;;"
+ ResponseURL);
Log.d("Response: ", "> " + JsonStr);
return null;
}
#Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (pDialog.isShowing())
pDialog.dismiss();
try {
countDownTimer.cancel();
pg_loading.setProgress(0);
progressStatus = 0;
new Thread(new Runnable() {
public void run() {
while (progressStatus < 100) {
progressStatus += 1;
// Update the progress bar and display the
// current value in the text view
handler.post(new Runnable() {
public void run() {
if (run) {
pg_loading.setProgress(progressStatus);
pg_loading
.setProgressDrawable(getResources()
.getDrawable(
R.drawable.progress));
}
}
});
try {
// Sleep for 200 milliseconds.
// Just to display the progress slowly
Thread.sleep(62);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
questionTask(count);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public int randomGenerator() {
Random r = new Random();
int ans = r.nextInt(4 - 1) + 1;
return ans;
}
}
You can easily hold some boolean variable for that case:
private boolean run = true;
then gather all the Buttons onClickListeners in one click listener, like the main one of the class, and upon anyclick make that variable run=false, So, check that before set the progress:
if(run){
pg_loading.setProgress(progressStatus);
}else{
//stop, finish, do whatever you want
}
in onClick listener:
public void onClick(View v) {
// TODO Auto-generated method stub
run = false;
Intent i;
switch (v.getId()) {
.
.
.
}
UPDATE:
make the thread as the following:
new Thread(new Runnable() {
public void run() {
while (progressStatus < 100) {
progressStatus += 1;
// Update the progress bar and display the
// current value in the text view
handler.post(new Runnable() {
public void run() {
if(run){
pg_loading.setProgress(progressStatus);
pg_loading.setProgressDrawable(getResources()
.getDrawable(R.drawable.progress));
}
}
});
try {
// Sleep for 200 milliseconds.
// Just to display the progress slowly
Thread.sleep(62);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
UPDATE 2:
your onPostExcute in the AsyncTask must be:
#Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (pDialog.isShowing())
pDialog.dismiss();
try {
countDownTimer.cancel();
pg_loading.setProgress(0);
progressStatus = 0;
new Thread(new Runnable() {
public void run() {
while (progressStatus < 100) {
progressStatus += 1;
// Update the progress bar and display the
// current value in the text view
handler.post(new Runnable() {
public void run() {
pg_loading.setProgress(progressStatus);
pg_loading
.setProgressDrawable(getResources()
.getDrawable(
R.drawable.progress));
}
});

How to know when scroll animation is finished?

I do a smooth scroll to defined position.
smoothScrollTo(0, 1000);
After this method execute - i do a couple operations. But i want to do they - after scroll animation end.
I want to detect when scroll animation is finished. How i can do that?
i have do like this,
final ScrollView mScrollView = (ScrollView) findViewById(R.id.scrollview);
layoutSponsorBax.setVisibility(View.VISIBLE);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
#Override
public void run() {
runOnUiThread(new Runnable() {
#Override
public void run() {
ViewGroup relativeL = (ViewGroup) mScrollView
.getChildAt(mScrollView.getChildCount() - 1);
final int sVH = mScrollView.getBottom()
- mScrollView.getTop();
View notePad = relativeL.getChildAt(2);
final int svHeight = 800;
Log.i("svHeight", "svHeight : " + svHeight);
final float duration = 2000;
ctt = new CountDownTimer((int) duration, 1) {
int temp = 0;
public void onTick(long millisUntilFinished) {
try {
Log.i("millisUntilFinished",
"millisUntilFinished : "
+ millisUntilFinished);
Log.i("Height- Temp", "Temp : " + temp);
mScrollView.scrollTo(0, temp);
temp = (int) (((svHeight) - (millisUntilFinished / duration)
* (svHeight)));
} catch (ArithmeticException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public void onFinish() {
}
}.start();
}
});
}
};
int duration = 1400;
timer.schedule(task, duration);
please check this it may be help to you

Android: TextView Locked for update

I have a thread that start playing mp3 file, in this thread i update my TextView after round trip i use other thred to update my player and my TextView but in this case the textview not updated ?!
public void updatePlayProgressUpdater() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mediaLengthInSeconds = sharedPreferences.getLong("mediaLengthInSeconds", 0);
float mediaPositionSeconds = sharedPreferences.getFloat("mediaPositionSeconds", 0);
float progress = (mediaPositionSeconds / mediaLengthInSeconds);
sb.setProgress((int) (progress * 100));
sb.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
seekChange(v);
return false;
}
});
try {
textStreamed
.setText(convertDuration(mediaPlayer.getCurrentPosition() / 1000)
+ "/" + convertDuration(mediaLengthInSeconds));
} catch (Exception e) {
Log.v("Exception","");
}
Runnable notification = new Runnable() {
public void run() {
updatePlayProgressUpdater();
}
};
handler.postDelayed(notification, 1000);
}
...
Runnable notification = new Runnable() {
public void run() {
startPlayProgressUpdater();
}
};
...
// comment ...
public void startPlayProgressUpdater() {
mediaLengthInSeconds = mediaPlayer.getDuration() / 1000;
float mediaPositionSeconds = mediaPlayer.getCurrentPosition() / 1000;
float progress = (mediaPositionSeconds / mediaLengthInSeconds);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putLong("mediaLengthInSeconds", mediaLengthInSeconds);
editor.putFloat("mediaPositionSeconds", mediaPositionSeconds);
editor.commit(); // I missed to save the data to preference here,.
sb.setProgress((int) (progress * 100));
// playButton.setImageResource(R.drawable.pause);
sb.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
seekChange(v);
return false;
}
});
textStreamed
.setText(convertDuration(mediaPlayer.getCurrentPosition() / 1000)
+ "/" + convertDuration(mediaLengthInSeconds));
if (mediaPlayer.isPlaying()) {
Runnable notification = new Runnable() {
public void run() {
startPlayProgressUpdater();
}
};
handler.postDelayed(notification, 1000);
}
}
...
private void LoadPreferences(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
int state = sharedPreferences.getInt("stateDB", 0);
sb.setProgress(state);
textStreamed.setText(sharedPreferences.getString("statetextStreamed", ""));
coursTitle.setText(sharedPreferences.getString("coursTitle", ""));
coursIntervenant.setText(sharedPreferences.getString("coursIntervenant", ""));
new Thread() {
public void run() {
try {
runOnUiThread(new Runnable() {
#Override
public void run() {
updatePlayProgressUpdater();
}
});
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
...
#Override
protected void onResume() {
super.onResume();
LoadPreferences();
}
When you create an app, there is a single main thread (referred to as the UI thread) that handles all UI updating. Other threads you create cannot update the UI directly. It sounds like you have two update methods, one being called from the UI thread and one from a background thread.
There are many articles that explain it better than I can, such as http://developer.android.com/training/multiple-threads/communicate-ui.html.
on line 525 replace startPlayProgressUpdater(); with:
Runnable notification = new Runnable() {
public void run() {
startPlayProgressUpdater();
}
};
handler.postDelayed(notification, 1000);

Categories

Resources