Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
+ Reply Subscribe
Results 1 to 1 of 1
  1. Thread Author  Thread Author    #1  
    AC Question
    AC Question's Avatar
    Guest

    Post Android :Timer issue - Android app unable to have consistent timer in

    We are developing a unique android java app which sends pictures to friends to solve a puzzle (just like Instagram) while using the app when there is an interruption for e.g., a call, or when device goes to sleep , a new timer starts running along with the old timer simultaneously. Can you guys suggest on how to resolve this bug ?
    i.e.,
    Seconds Remaining : 178 seconds
    Seconds Remaining : 156 seconds
    Seconds Remaining : 177 seconds
    Seconds Remaining : 155 seconds
    Seconds Remaining : 176 seconds
    Seconds Remaining : 154 seconds
    Seconds Remaining : 175 seconds
    Seconds Remaining : 154 seconds

    This is how the timer output is

    Please find the relevant code below:
    [sourcecode]
    countDownTimer = new CountDownTimer(180000, 1000) {

    public void onTick(long millisUntilFinished) {
    // how.setText(millisUntilFinished / 1000 + "seconds remaining: " );
    if(countTime.equals("yes"))
    {
    how.setText(count+" ");
    //how.setText(millisUntilFinished / 1000 );
    }
    else
    {
    //how.setText(count+" Seconds");
    how.setText(millisUntilFinished / 1000 + " seconds remaining" );
    }
    how.setTextSize(30);
    count++;
    if(count==180)
    {
    T.cancel();
    T=null;


    handler.postDelayed(new Runnable() {
    @Override
    public void run() {
    MainActivity.this.finish();
    }
    }, 5000);

    }
    }

    public void onFinish() {
    how.setText("Time Is Up!");
    }
    }.start();
    [/sourcecode]

Similar Threads

  1. "DEVICE OVERHEATING" Message and Apps Closing
    By intelkw in forum Samsung Galaxy Note 8.0
    Replies: 7
    Last Post: 11-18-2014, 07:47 PM
  2. Replies: 20
    Last Post: 08-21-2014, 04:28 PM
  3. Does screen mirroring work from phone to tablet?
    By krynn72 in forum Samsung Galaxy S5
    Replies: 4
    Last Post: 07-22-2014, 11:34 AM
  4. Hangouts app theme
    By Beedog1221 in forum Ask a Question
    Replies: 1
    Last Post: 07-21-2014, 11:49 PM
  5. solution to reinstall apps
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 07-21-2014, 11:45 PM

Posting Permissions