java - why am i getting an illegal argument exception from this code? -


this code written following tutorial: http://www.techsono.com/consult/update-android-gui-timer/

i don't understand why i'm getting illegal argument exception code when try , run on device. i'm not whats causing illegal argument exception either. code i'm running attempt make client connects server @ ip address (this ip address changed) in order receive information update android gui show said information. text views in starting layout whats being updated in gui if helps?

i apologize in advance if explanation of seems bit confusing, confusing me :3 think understand codes doing clarification on code , why isn't working , whats problem great.

heres code:

package com.example.clienttest;  import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.net.socket; import java.util.timer; import java.util.timertask; import java.util.concurrent.timeunit;  import android.app.activity; import android.os.bundle; import android.os.handler; import android.view.menu; import android.widget.textview;  public class clienttestmain extends activity {  final handler myhandler = new handler();  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_client_test_main);       timer mytimer = new timer();     mytimer.schedule(new timertask(){         @override         public void run(){             updategui();}},0,0);         }   final runnable myrunnable = new runnable(){             @override             public void run(){                  textview header = (textview) findviewbyid(r.id.textview4);                 textview time = (textview) findviewbyid(r.id.textview4);                 textview trackid = (textview) findviewbyid(r.id.textview4);                 textview latitude = (textview) findviewbyid(r.id.textview4);                 textview longitude = (textview) findviewbyid(r.id.textview4);                 textview depth = (textview) findviewbyid(r.id.textview4);                 textview speed = (textview) findviewbyid(r.id.textview4);                 textview heading = (textview) findviewbyid(r.id.textview4);                  try{                     while(true){                     socket infosocket = new socket("128.23.1.0", 2000);                     inputstreamreader stream = new inputstreamreader(infosocket.getinputstream());                     bufferedreader reader = new bufferedreader(stream);                     string message = reader.readline();                     string[] op = message.split(",");                     header.settext(op[0]);                     time.settext(op[1]);                     trackid.settext(op[2]);                     latitude.settext(op[3]);                     longitude.settext(op[4]);                     depth.settext(op[5]);                     speed.settext(op[6]);                     heading.settext(op[7]);                     timeunit.seconds.sleep(1);                     }                 }catch(ioexception ex){                     ex.printstacktrace();                 }catch (interruptedexception e) {                 }              }};      private void updategui(){       myhandler.post(myrunnable);   }    @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.client_test_main, menu);     return true; }  } 

heres logcat:

09-04 12:04:23.453: d/androidruntime(18628): shutting down vm 09-04 12:04:23.453: w/dalvikvm(18628): threadid=1: thread exiting uncaught exception    (group=0x40bea1f8) 09-04 12:04:23.453: e/androidruntime(18628): fatal exception: main 09-04 12:04:23.453: e/androidruntime(18628): java.lang.runtimeexception: unable start  activity componentinfo{com.example.clienttest/com.example.clienttest.clienttestmain}: java.lang.illegalargumentexception 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread.performlaunchactivity(activitythread.java:1970) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:1995) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread.access$600(activitythread.java:128) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread$h.handlemessage(activitythread.java:1161) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.os.handler.dispatchmessage(handler.java:99) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.os.looper.loop(looper.java:137) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread.main(activitythread.java:4514) 09-04 12:04:23.453: e/androidruntime(18628):    @ java.lang.reflect.method.invokenative(native method) 09-04 12:04:23.453: e/androidruntime(18628):    @ java.lang.reflect.method.invoke(method.java:511) 09-04 12:04:23.453: e/androidruntime(18628):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:790) 09-04 12:04:23.453: e/androidruntime(18628):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) 09-04 12:04:23.453: e/androidruntime(18628):    @ dalvik.system.nativestart.main(native method) 09-04 12:04:23.453: e/androidruntime(18628): caused by: java.lang.illegalargumentexception 09-04 12:04:23.453: e/androidruntime(18628):    @ java.util.timer.schedule(timer.java:479) 09-04 12:04:23.453: e/androidruntime(18628):    @ com.example.clienttest.clienttestmain.oncreate(clienttestmain.java:28) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activity.performcreate(activity.java:4465) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1053) 09-04 12:04:23.453: e/androidruntime(18628):    @ android.app.activitythread.performlaunchactivity(activitythread.java:1934) 09-04 12:04:23.453: e/androidruntime(18628):    ... 11 more 09-04 12:09:29.781: i/process(18628): sending signal. pid: 18628 sig: 9 

you cannot pass period value = 0

throws

illegalargumentexception if delay < 0 or period <= 0.

illegalstateexception if timer has been canceled, or if task has been scheduled or canceled.

mytimer.schedule(new timertask(){         @override         public void run(){             updategui();}},0,1000); //update here         } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -