android - Converting a code from API 9 to API 8 ( TimeUnit) -
I'm trying to make a countdown timer, working with Android 2.2 (API 8). I got this code but it works only with API 9 and above How do I get this code in API 8?
// API 9 and public square CountClass up CountDownTimer {public CountClass (long millisInFuture, long countDownInterval) extends {super (millisInFuture, countDownInterval); // TODO Auto-generated constructor stub} @Override public void onFinish () {// TODO Auto-generated method stub txtchronoview.setText ( "full."); Toast.makeText (calculator1.this, Toast.LENGTH_SHORT "call a judge, but more than your opponent to the limit of 3 minutes per turn,") .show (); Vibrate (3000); // pu ka rawa na (); } @TargetApi (Build.VERSION_CODES.GINGERBREAD) @Override public void onTick (long millisUntilFinished) {// TODO Auto-generated method stub has long seconds = millisUntilFinished; String HMS = String.Format ( "% 02d:% 02d:% 02d", TimeUnit.MILLISECONDS.toHours (milliseconds), (TimeUnit.MILLISECONDS.toMinutes (milliseconds) - TimeUnit.HOURS.toMinutes (TimeUnit.MILLISECONDS.toMinutes (Milliseconds) / 60000), // display 3 min below //(TimeUnit.MILLISECONDS.toMinutes (millis COUNT) - TimeUnit.HOURS.toMinutes (TimeUnit.MILLISECONDS.toMinutes (milliseconds)) / 60), // Demonstration for 1 minute COUNT 3 years down cycle // (Time Unit. MILISLX) Minutes (Emilis) - Time Unit, HOURS.T minutes (Time Unit, Milliseconds, Minimates (Millise)), // for 3 minutes Display all A Unilikvends. Unit. MILILC & C.Second (Million) - Time Unit MINUTSSESSCunds (TYMUNIT.ILILXXSTMT (MILLIS))); Println (HMS); Txtchronoview.setText (HMS); }}
use this for minutes and seconds, with small changes u Hours can add.
Public string millisecotomy and ac (long millisec) {int compress = (int) millisec / 1000; String outstring = ""; If (sec & gt; 60) outString = String.Format ("% 02d", (int) (second / 60)) + ":" + String.Format ("% 02d", (int) (second 60%) ); And outside string = "00:" + string Format ("% 02d", sec); Return withdrawal string; }
Comments
Post a Comment