title: Making remote server calls in an Android application
body: <p>I've made an apache thrift server and I have a service which contains several functions.
  I'm trying to figure out what is the best way to make calls to the remote server from my android application.</p>
  <p>My problem is that I can't make calls from the MainActivity thread (the main thread) - and I need to use most of the remote functions in my main activity methods.</p>
  <p>I tried to make a static class with a static member called &quot;Server&quot; equals to the server object, and I set it in another thread and then I tried to call it in the main thread (the main activity class) - but I had errors because of jumping from one thread to another..</p>
  <p>To be more specified I want something like that:</p>
  <pre><code>public class MainActivity extends Activity {
    private service.Client myService;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      ..
      ... Some stuff that define myService (In a new thread ofcourse) ...
    }
  
    ...
    
    private void MyFunc1() {
      myService.Method1();
    }
  
    private void MyFunc2() {
      myService.Method2();
    }
  
    private void MyFunc3() {
      myService.Method3();
    }
  }
  </code></pre>