title: Get NullPointerException after Fragment call interface method
body: <p>I am new in Rest Template, when I call @background from MainActivity for retrieving data from rest server, it is fine. But after I call it from Fragment, it doesn't wok.</p>
  
  <p>Here is my Main:</p>
  
  <pre><code>package com.example.androidkickstart;
  
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.view.ViewPager;
  import android.support.v4.view.ViewPager.OnPageChangeListener;
  import android.util.Log;
  import android.widget.ListView;
  
  import com.actionbarsherlock.app.ActionBar;
  import com.actionbarsherlock.app.ActionBar.Tab;
  import com.actionbarsherlock.app.ActionBar.TabListener;
  import com.actionbarsherlock.app.SherlockFragmentActivity;
  import com.actionbarsherlock.view.Menu;
  import com.example.androidkickstart.adapter.ViewPagerAdapter;
  import com.example.androidkickstart.object.MoviesList;
  import com.example.androidkickstart.rest.RestClient;
  import com.example.androidkickstart.rest.getMovieListAsync;
  import com.googlecode.androidannotations.annotations.AfterViews;
  import com.googlecode.androidannotations.annotations.Background;
  import com.googlecode.androidannotations.annotations.EActivity;
  import com.googlecode.androidannotations.annotations.UiThread;
  import com.googlecode.androidannotations.annotations.ViewById;
  import com.googlecode.androidannotations.annotations.rest.RestService;
  
  @EActivity(R.layout.activity_main)  
  public class MainActivity
  extends SherlockFragmentActivity
  implements OnPageChangeListener, TabListener
  {
  
  /******* Declare Class *******/
  @RestService
  RestClient restClient;          
  
  /******* Variable Declaration *******/
  private String[] locations; 
  MoviesList movieList;
  
  /******* View Declaration *******/
  @ViewById                       
  ViewPager pager;                
  ListView List;
  
  
  /********** Things to do after View Declaration *********/
  @AfterViews
  void afterViews() {
      locations = getResources().getStringArray(R.array.locations);
      configureViewPager();
      configureActionBar();
      doSomethingInBackground();
  }
  
  
  /******* samilar to OnPostExecute, OnPreExecute *******/
  @UiThread
  void doSomethingElseOnUiThread() {
      // do something on UIThread
  }
  
  @Background
  void doSomethingInBackground() {
      movieList=restClient.main();
      doSomethingElseOnUiThread();
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getSupportMenuInflater();
      return true;
  }
  
  private void configureViewPager() {
      ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager(), locations);
      pager.setAdapter(viewPagerAdapter);
      pager.setOnPageChangeListener(this);
  }
  
  public void onPageSelected(int position) {
      Tab tab = getSupportActionBar().getTabAt(position);
      getSupportActionBar().selectTab(tab);
  }
  
  private void configureActionBar() {
      getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      for (String location: locations) {
          Tab tab = getSupportActionBar().newTab();
          tab.setText(location);
          tab.setTabListener(this);
          getSupportActionBar().addTab(tab);
      }
  }
  
  @Override
  public void onTabSelected(Tab tab, FragmentTransaction ft) {
      int position = tab.getPosition();
      pager.setCurrentItem(position);
  }
  @Override
  public void onPageScrollStateChanged(int position) {}@Override
   public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)     {}@Override
   public void onTabUnselected(Tab tab, FragmentTransaction ft) {}@Override
  public void onTabReselected(Tab tab, FragmentTransaction ft) {}
  }
  </code></pre>
  
  <p>Here is my RestClient:</p>
  
  <pre><code>package com.example.androidkickstart.rest;
  
  import com.example.androidkickstart.object.MoviesList;
  import com.googlecode.androidannotations.annotations.rest.Get;
  import com.googlecode.androidannotations.annotations.rest.Rest;
  import org.springframework.http.converter.StringHttpMessageConverter;
  import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;;
  
  @Rest(rootUrl = "http://mubi-app.herokuapp.com", converters = MappingJacksonHttpMessageConverter.class)
  public interface RestClient {
  
  
  @Get("/api/v1/home")
  public MoviesList main();
  
  }
  </code></pre>
  
  <p>But when i call my RestClient from MovieListFragment(Fragment), i got a weird problem.
  Here is my MovieListFragment...</p>
  
  <pre><code>package com.example.androidkickstart;
  
   import java.util.ArrayList;
  
   import android.content.Context;
   import android.os.Bundle;
   import android.support.v4.app.Fragment;
   import android.util.Log;
   import android.view.LayoutInflater;
   import android.view.View;
   import android.view.ViewGroup;
   import android.widget.ArrayAdapter;
   import android.widget.ListView;
   import android.widget.SimpleAdapter;
   import android.widget.TextView;
  
   import com.example.androidkickstart.adapter.BaseAdapter;
   import com.example.androidkickstart.object.MoviesList;
   import com.example.androidkickstart.object.movies;
   import com.example.androidkickstart.rest.RestClient;
   import com.googlecode.androidannotations.annotations.AfterViews;
   import com.googlecode.androidannotations.annotations.Background;
   import com.googlecode.androidannotations.annotations.EFragment;
   import com.googlecode.androidannotations.annotations.UiThread;
  
   import com.googlecode.androidannotations.annotations.ViewById;
   import com.googlecode.androidannotations.annotations.rest.RestService;
  
  @EFragment(R.layout.layout_main)
  public class MovieListFragment
   extends Fragment
  {
  
  View v;
  MoviesList moviesList;
  BaseAdapter adapter;
  Context context;
  
  @RestService
  RestClient restClientFragment;
  
  @ViewById
  TextView txtMovieList;
  ListView list;
  
  @AfterViews
  void afterViews() {     
  
      txtMovieList.setText("Movie LIst");
      doSomethingInBackground();
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
      v=inflater.inflate(R.layout.layout_main, null); 
      return v;
  }
  
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {  
      super.onViewCreated(view, savedInstanceState);
      context=view.getContext();
      txtMovieList=(TextView)v.findViewById(R.id.txtMovieList);
      list=(ListView)v.findViewById(R.id.list);
      afterViews();
  
  }
  /******* samilar to OnPostExecute, OnPreExecute *******/
  @UiThread
  void doSomethingElseOnUiThread() {
      // do something on UIThread
  }
  
  @Background
  void doSomethingInBackground() {
      String str=restClientFragment.main().toString();
      doSomethingElseOnUiThread();
  }
  }
  </code></pre>
  
  <p>And here is my error...</p>
  
  <pre><code>06-17 11:17:07.919: E/AndroidRuntime(791): FATAL EXCEPTION: main
  06-17 11:17:07.919: E/AndroidRuntime(791): java.lang.NullPointerException
  06-17 11:17:07.919: E/AndroidRuntime(791):  at com.example.androidkickstart.MovieListFragment.doSomethingInBackground(MovieListFragment.java:88)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at com.example.androidkickstart.MovieListFragment.afterViews(MovieListFragment.java:62)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at com.example.androidkickstart.MovieListFragment.onViewCreated(MovieListFragment.java:76)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:925)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.View.measure(View.java:8313)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.ViewRoot.performTraversals(ViewRoot.java:843)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1863)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.os.Handler.dispatchMessage(Handler.java:99)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.os.Looper.loop(Looper.java:130)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at android.app.ActivityThread.main(ActivityThread.java:3768)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at java.lang.reflect.Method.invokeNative(Native Method)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at java.lang.reflect.Method.invoke(Method.java:507)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
  06-17 11:17:07.919: E/AndroidRuntime(791):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I have spent a couple of hours to solve this problem, but i am new user of rest template, and i also don't have a good knowledge of how rest template work. I am hoping someone to get me out of this problem. </p>
  
  <p>Thanks,</p>