I've been trying to do timed tasks with a handler in Android Studio, but when I try to initialize it, this happens:
private Handler handler = new Handler() {
@Override
public void publish(LogRecord record) {
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
};
Whenever I look at online examples where people use Handlers to execute code at intervals, their declarations look as such:
private Handler handler = new Handler();
How do I avoid the big jumble of methods within the Handler?
Looks like you're trying to use java.util.logging.Handler instead of android.os.Handler. Changing which one you import at the top of the file should fix your problem.
The auto-complete should show you which packages you will be importing from, so watch out for that in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With