gsources75
Lurker
Hi, I know to load data from WebService o load other resource i need to creare a separate Thread. Ok i tryed and i't ok but all example show Thread inside the class but i'd like create a system of message between class, a second class load and parse data adn after sen data to firt class.
Sorry for mybad english, there is the code
package com.example;
import android.app.Activity;
import android.os.Bundle;
I would have the task of loading data is given to the second class and after send data to MainClass. I don't want create UtilClass as Activity
Sorry for mybad english, there is the code
package com.example;
import android.app.Activity;
import android.os.Bundle;
Code:
public class MainClass extends Activity {
private UtilClass u_load;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
u_load= new UtilClass();
u_load.loadData("http://www.mysite.com/data.xml");
}
}
Code:
package com.example;
public class UtilClass {
public UtilClass() {
// TODO Auto-generated constructor stub
}
void loadData(String path){
Thread t = new Thread() {
public void run() {
mResults = doSomethingExpensive();
mHandler.post(mUpdateResults);
}
};
t.start();
}
}
I would have the task of loading data is given to the second class and after send data to MainClass. I don't want create UtilClass as Activity