I am working on android app. I need to get data from my server.I was making the server call from acitivity and got java.lang.reflect.invocationtargetexception because I was doing it on main android thread. To over come this ,I simply create a new thread and called thread.join for it to complete.I want to know is there any side effect of using such code? I tried using handler and async executor but the code became messy. Would Appreciate help. Thanks!
Runnable runnable=new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
nearCars=getNearCars();
}
};
Thread t=new Thread(runnable);
t.start();
try {
t.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}