java - Error with the bundle on a new thread -


i have problem. created tcp client executes in new thread connection server. unfortunately, program shuts down. in logcat following message:

"fatal exception: thread-14635      process: com.example.sebastian.ravia, pid: 8648      java.lang.nullpointerexception: attempt invoke virtual method 'android.os.bundle android.content.intent.getextras () on null object reference              @ com.example.sebastian.ravia.clientthread.run (tcpclient.java:36)              @ java.lang.thread.run (thread.java:818)

the problem in: "bundle przekazanedane". bundle download text string of edittext previous activity.

here's code:

public class tcpclient extends activity  { //private socket socketin; //private socket socketout;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.client_activity);      new thread(new clientthread()).start(); } }  class clientthread extends tcpclient implements runnable {  private boolean arun = false;  private string ahost; private string asocketin; private string asocketout;  public void run() {      bundle przekazanedane = getintent().getextras();      if(przekazanedane != null) {         ahost = przekazanedane.getstring("addressip");         asocketin = przekazanedane.getstring("socketin");         asocketout = przekazanedane.getstring("socketout");     }      int asocketinint;     int asocketoutint;      arun = true;      asocketinint = integer.parseint(asocketin);     asocketoutint = integer.parseint(asocketout);      try {         inetaddress serweraddress = inetaddress.getbyname(ahost);          socket socket = new socket(serweraddress, asocketinint);          printwriter out = new printwriter(socket.getoutputstream(),true);         bufferedreader in = new bufferedreader(new inputstreamreader(socket.getinputstream()));     }     catch (exception e) {          e.printstacktrace();      } } } 


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -