0
我有一個顯示倒計時的小部件。爲了做到這一點,我使用CountDownTimer類,但問題是倒計時經常停止!我認爲,因爲android自動停止線程,因爲在很多houres期間countdownc。你可以解決這個問題嗎?謝謝Android stop CountDown
public class TempoIndietro extends CountDownTimer{
AppWidgetManager manager;
ComponentName thisWidget;
public TempoIndietro(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
thisWidget = new ComponentName(context, widget.class);
manager = AppWidgetManager.getInstance(context);
remoteView = new RemoteViews(context.getPackageName(),R.layout.widgett);
}
@Override
public void onFinish() {
remoteView.setTextViewText(R.id.textView2, context.getResources().getString(R.string.onair_widget_countdown));
manager.updateAppWidget(thisWidget, remoteView);
}
@Override
public void onTick(long millisUntilFinished) {
SimpleTimeFormat tf = new SimpleTimeFormat("$dd$ : $HH$: $mm$: $ss$");
String risultato = tf.format(millisUntilFinished); // arg0 tempo
remoteView.setTextViewText(R.id.textView2, risultato);
manager.updateAppWidget(thisWidget, remoteView);
};
}
怎麼是你應該來幫助你看到你的代碼 – slayton 2012-04-19 21:09:26
我有加入倒數代碼到答案 – MimmoG 2012-04-19 22:10:35
當onTick()執行的呢?換句話說,何時更新小部件?在每一分鐘? – San 2012-04-19 22:53:24