Hi, .when the activity is visible there isnt any problem.but when i navigate to previous screen and again going to this activity it causes forced close to my app. how to resolve this?
On Tue, Jun 21, 2011 at 12:41 AM, Zsolt Vasvari <[email protected]> wrote: > Ok, cool. Do you have a question? > > On Jun 21, 3:35 pm, Hitendrasinh Gohil <[email protected]> > wrote: > > Hi, > > > > I am using thread in my activity class.when the activity is visible > > there isnt any problem.but when i navigate to previous screen and > > again going to this activity it causes forced close to my app.I have > > tried it by removing the thread then it works fine. > > > > Here is the code that i m calling from onCreate method. > > > > private void listenForTrackChange() > > { > > new Thread() > > { > > public void run() > > { > > if(!isSocketOpen) > > { > > try > > { > > try > > { > > String line; > > socket=new > Socket("host",1934); > > out = new > PrintWriter(socket.getOutputStream(), true); > > in = new BufferedReader(new > > InputStreamReader(socket.getInputStream())); > > out.println("OPEN CHANNEL > ARTIST > > "+StremingPlayer.CURRENTARTISTID); > > while > ((line=in.readLine())!=null) > > { > > String delimeter1="="; > > String delimeter2="&"; > > String > > > trackid=line.substring(line.indexOf(delimeter1),line.indexOf(delimeter2)); > > List<NameValuePair> > nameValues = new > > ArrayList<NameValuePair>(); > > > nameValues.add(new BasicNameValuePair("sid", > > > SplashScreen.sidvalue)); > > > HttpRetriever httpThread = new HttpRetriever( > > > UrlConstants.BASEURL + UrlConstants.TRACK+"&id"+trackid, > > nameValues, > > > StreamingPlayerView.this, UrlConstants.NEWSLISTINDEX); > > > httpThread.start(); > > > isSocketOpen=true; > > } > > > > } > > catch (IOException e) > > { > > e.printStackTrace(); > > } > > finally > > { > > try > > { > > if (in!=null) > > in.close(); > > } > > catch (IOException e) > {e.printStackTrace();}; > > if (out!=null) out.close(); > > try > > { > > if (socket!=null) > > socket.close(); > > isSocketOpen=false; > > } > > catch (IOException e) > > { > > e.printStackTrace(); > > }; > > } > > } > > catch (Exception e) > > { > > e.printStackTrace(); > > } > > } > > } > > }.start(); > > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Regards, Hitendrasinh Gohil -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

