Hello.I have an downloadservice.class for download data and i call it from
main activity inside onCreate.How i pass download data to main activity for
display as text?
public class DownloadService extends IntentService {
public String response;
public DownloadService() {
super("DownloadService");
}
// Will be called asynchronously be Android
@Override
protected void onHandleIntent(Intent intent) {
//String urldown = intent.getStringExtra("url");
String urldown="http://mplampla.net/LEDstate.txt";
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(urldown);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new
InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
//Arduwebled instance = new Arduwebled();
//instance.test(response);
// while (mOutputStream != null) {
//mOutputStream.write(buffer);
// }
} catch (IOException e) {
e.printStackTrace();
}
// Arduwebled instance = new Arduwebled();
// instance.test(response);
}
// Sucessful finished
}
public class Arduwebled extends Activity {
TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setup);
sendBroadcast(new Intent(this,MyScheduleReceiver.class));
}
public void test(String response){
TextView text = (TextView) findViewById(R.id.downdata);
text.setText(response);
}
public void StopRepeat(View view) {
sendBroadcast(new Intent(this,MyStopReceiver.class));
}
--
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