Results 1 to 3 of 3
- 05-24-2012, 08:28 PM #1
Member
- Join Date
- May 2012
- Posts
- 1
- Rep Power
- 0
java execute command every 10 seconds
Hello guys. I have this code, for a android app i'm working on. It reads from a .php page and outputs the text
It works fine but I would like it to "autorefresh" every 10 seconds, because the text from the php script is always changing. Sincerely i don`t know how to do that. Can you please help me solve this out? Thanks!Java Code:package com.exercise.AndroidInternetTxt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class AndroidInternetTxt extends Activity { TextView textMsg, textPrompt, textSite; final String textSource = "http://www.xxx/s.php"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textPrompt = (TextView)findViewById(R.id.textprompt); textMsg = (TextView)findViewById(R.id.textmsg); textSite = (TextView)findViewById(R.id.textsite); //textPrompt.setText("Asteapta..."); URL textUrl; try { textUrl = new URL(textSource); BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream())); String StringBuffer; String stringText = ""; while ((StringBuffer = bufferReader.readLine()) != null) { stringText += StringBuffer; } bufferReader.close(); textMsg.setText(stringText); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); textMsg.setText(e.toString()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); textMsg.setText(e.toString()); } //textPrompt.setText("Terminat!"); } }
- 05-24-2012, 08:46 PM #2
- 05-25-2012, 08:09 PM #3
Senior Member
- Join Date
- Apr 2012
- Posts
- 127
- Rep Power
- 0
Similar Threads
-
Cannot Execute java programs from the command prompt
By Manfizy in forum New To JavaReplies: 8Last Post: 03-13-2011, 11:03 AM -
Execute Cygwin command from Java app
By ZebraIzToronto in forum Advanced JavaReplies: 1Last Post: 01-21-2011, 05:51 AM -
How to use Timer class to schedule a task to execute once 5 seconds have passed
By Java Tip in forum java.utilReplies: 0Last Post: 06-26-2008, 07:32 PM -
Execute a jar command from a java program
By apremanandh in forum New To JavaReplies: 3Last Post: 05-21-2008, 02:04 PM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks