public void musicTimerTask(){ if(playTimerTask != null){ playTimerTask.cancel(); } if(playTimer != null){ playTimer.cancel(); } curStr = mMusicName; oldStr = " " + mMusicName + " "; playTimerTask = new TimerTask(){ public void run(){ len = oldStr.length(); if(index > len){ index = 0; } newStr = oldStr.substring(index) + oldStr.substring(0, index); index++; if(index >= len){ index = 0; } views.setTextViewText(R.id.TextView01, newStr); appManager.updateAppWidget(thisWidget, views); } }; playTimer = new Timer(true); playTimer.schedule(playTimerTask, 0,1000); }