Timer IllegalArgumentException with positive delay
<p>I've come across a crash report in one of my apps that appears to be something that should never happen in my code...</p>

<pre><code>java.lang.IllegalArgumentException
at java.util.Timer.schedule(Timer.java:461)
at com.pilot51.voicenotify.Service.onAccessibilityEvent(Service.java:177)
at android.accessibilityservice.AccessibilityService$IEventListenerWrapper.executeMessage(AccessibilityService.java:215)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p><br />
Here's the relevant code for that revision:</p>

<pre><code>int delay = 0;
try {
    delay = Integer.parseInt(Common.prefs.getString("ttsDelay", null));
} catch (NumberFormatException e) {}

if (delay &gt; 0) {
    final String msg = newMsg;
        new Timer().schedule(new TimerTask() { // This is line 177
        public void run() {
            speak(msg, true);
        }
    }, delay * 1000);
}
</code></pre>

<p>Full source: <a href="https://github.com/pilot51/voicenotify/blob/v1.0.9.1/src/com/pilot51/voicenotify/Service.java" rel="nofollow">https://github.com/pilot51/voicenotify/blob/v1.0.9.1/src/com/pilot51/voicenotify/Service.java</a><br />
<br />
I checked the Timer source and verified that IAE should only happen if <code>delay &lt; 0</code>, yet I have a check that <code>delay &gt; 0</code>. On top of that, unless there's some poorly designed custom keyboard that ignores input type/digits (is that even possible?), the user can only enter numbers 0-9 in the text field, no negative sign or period or anything else.<br />
<br />
Since I am unable to reproduce the crash or communicate with any users experiencing it, I am unable to debug it. The relative number of reports is high enough to have me a little concerned.</p>
