Question

I'm using for first time the CountDownTimer but, not working. Application crashes with this:

if(Game1.ifWorking == false) {
        new CountDownTimer (30000, 1000) {

            @Override
            public void onFinish() {
                Game1.ifWorking = false;
                Game1.points = 0;
            }

            @Override
            public void onTick(long millisUntilFinished) {
                Game1.ifWorking = true;
                crono.setText("Test" + millisUntilFinished / 1000);
            }

        }.start();
    }

Variable:

private static boolean ifWorking;

What is the problem?

EDIT:

LogCat: http://i.gyazo.com/b20c01f75d173edf3ee1a5a8569423ab.png

Was it helpful?

Solution

The View crono is null. Initialise your view and then call setText: crono.setText("Test" + millisUntilFinished / 1000);

OTHER TIPS

Do This tell me the error If app is just on your own local device, you can use LogCat. Even if the device wasn't connected to a host machine when the crash occurred, connecting the device and issuing an adb logcat command will download the entire logcat history (at least to the extent that it is buffered which is usually a lot of log data, it's just not infinite).While i check for this CountDownTimer func.

TRY this

package com.tutorialspoint;

import java.lang.*;

public class BooleanDemo {

   public static void main(String[] args) {

      // create 2 Boolean objects b1, b2
      Boolean b1, b2;

      // create a boolean primitive res
      boolean res;

      // assign values to b1, b2
      b1 = new Boolean(true);
      b2 = new Boolean(false);

      // assign the result of equals method on b1, b2 to res
      res = b1.equals(b2);

      String str = "b1:" +b1+ " and b2:" +b2+ " are equal is " + res;

      // print res value
      System.out.println( str );
   }
}
Let us compile and run the above program, this will produce the following result:

b1:true and b2:false are equal is false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top