title: Android Retrofit GET
body: <p>I am new to Retrofit and built a simple app using it. But when I tried to run the app, it didn't display the data fetched from the web. However, the api hits are increasing each time. Kindly help me solve this out. 
  Thanks in advance.</p>
  
  <p>Main Activity:</p>
  
  <pre><code>package com.vyshnav.trainname;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.vyshnav.trainname.model.Days;
  import com.vyshnav.trainname.model.Train;
  import com.vyshnav.trainname.model.TrainNameResponse;
  import com.vyshnav.trainname.rest.ApiClient;
  import com.vyshnav.trainname.rest.ApiInterface;
  
  import java.util.List;
  
  import retrofit2.Call;
  import retrofit2.Callback;
  import retrofit2.Response;
  
  public class MainActivity extends AppCompatActivity {
  
  // API KEY: iqccq8931
  
  
  // TODO - insert your themoviedb.org API KEY here
  private final static String API_KEY = "iqccq8931";
  private final static String TRAIN_NAME = "BHOPAL EXPRESS";
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      if (API_KEY.isEmpty()) {
          Toast.makeText(getApplicationContext(), "Please obtain your API KEY first from themoviedb.org", Toast.LENGTH_LONG).show();
          return;
      }
  
      ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class);
      Call&lt;TrainNameResponse&gt; call = apiService.getTrainNameResponse(TRAIN_NAME,API_KEY);
      call.enqueue(new Callback&lt;TrainNameResponse&gt;() {
          @Override
          public void onResponse(Call&lt;TrainNameResponse&gt;call, Response&lt;TrainNameResponse&gt; response) {
            //  Class&lt;Train&gt; trainObj = response.body().getTrain();
  
              String tv1 = response.body().getTrain().getName();
              TextView textView = (TextView) findViewById(R.id.tv1);
              textView.setText(tv1);
  
              int tv2 = response.body().getResponse_code();
              TextView textView2 = (TextView) findViewById(R.id.tv2);
              textView2.setText(tv2);
          }
  
          @Override
          public void onFailure(Call&lt;TrainNameResponse&gt;call, Throwable t) {
              // Log error here since request failed
          }
      });
  }
  
  }
  </code></pre>
  
  <p>ApiClient.java</p>
  
  <pre><code>package com.vyshnav.trainname.rest;
  
  import retrofit2.Retrofit;
  import retrofit2.converter.gson.GsonConverterFactory;
  
  
  
  public class ApiClient {
  
  public static final String BASE_URL = "http://api.railwayapi.com/name_number/";
  private static Retrofit retrofit = null;
  
  
  public static Retrofit getClient() {
      if (retrofit==null) {
          retrofit = new Retrofit.Builder()
                  .baseUrl(BASE_URL)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
      }
      return retrofit;
  }
  }
  </code></pre>
  
  <p>ApiInterface.java</p>
  
  <pre><code>package com.vyshnav.trainname.rest;
  
  import com.vyshnav.trainname.model.TrainNameResponse;
  
  import retrofit2.Call;
  import retrofit2.http.GET;
  import retrofit2.http.Path;
  import retrofit2.http.Query;
  
  /**
   * Created by Vyshnav on 15-08-2016.
   */
  
  public interface ApiInterface {
  
  @GET("train/{name}/apikey/{apikey}/")
  Call&lt;TrainNameResponse&gt; getTrainNameResponse(@Path("name") String name, @Path("apikey") String apiKey);
  }
  </code></pre>
  
  <p>TrainNameResponse.java</p>
  
  <pre><code>package com.vyshnav.trainname.model;
  
  import com.google.gson.annotations.SerializedName;
  
  
  public class TrainNameResponse {
  
  @SerializedName("train")
  Class&lt;Train&gt; train;
  @SerializedName("response_code")
  int response_code;
  
  public TrainNameResponse(Class&lt;Train&gt; train,int response_code) {
      this.train = train;
      this.response_code = response_code;
  }
  
  public Class&lt;Train&gt; getTrain() {
  
      return train;
  }
  
  public void setTrain(Class&lt;Train&gt; train) {
  
      this.train = train;
  }
  
  public int getResponse_code() {
  
      return response_code;
  }
  
  public void setResponse_code(int response_code) {
  
      this.response_code = response_code;
  }
  }
  </code></pre>
  
  <p>Train.java</p>
  
  <pre><code>package com.vyshnav.trainname.model;
  
  import com.google.gson.annotations.SerializedName;
  
  import java.util.List;
  
  
  public class Train {
  
  @SerializedName("days")
  private List&lt;Days&gt; days;
  @SerializedName("name")
  private String name;
  @SerializedName("number")
  private String number;
  
  public Train(List&lt;Days&gt; days,String name, String number) {
      this.days = days;
      this.name = name;
      this. number = number;
  }
  
  public List&lt;Days&gt; getDays() {
  
      return days;
  }
  
  public void setDays(List&lt;Days&gt; days) {
  
      this.days = days;
  }
  
  public String getName() {
  
      return name;
  }
  
  public void setName(String name) {
  
      this.name = name;
  }
  
  public String getNumber() {
  
      return number;
  }
  
  public void setNumber(String number) {
  
      this.number = number;
  }
  
  
  }
  </code></pre>
  
  <p>Days.java</p>
  
  <pre><code>package com.vyshnav.trainname.model;
  
  import com.google.gson.annotations.SerializedName;
  
  public class Days {
  
  @SerializedName("runs")
  private String runs;
  @SerializedName("day-code")
  private String daycode;
  
  public Days (String runs,String daycode) {
      this.runs = runs;
      this.daycode = daycode;
  }
  
  public String getRuns() {
      return runs;
  }
  
  public void setRuns(String runs) {
      this.runs = runs;
  }
  
  public String getDaycode() {
      return daycode;
  }
  
  public void setDaycode(String daycode) {
      this.daycode = daycode;
  }
  }
  </code></pre>
  
  <p>Why are only some getters and setters coloured in orange while some others are not?</p>
  
  <p>Also I found 2 issues in logcat though the app is not crashing.
  Logcat:</p>
  
  <pre><code>08-16 16:23:25.032 13558-13558/com.vyshnav.trainname D/AccessibilityManager: setStateLocked: wasEnabled = false, mIsEnabled = false, wasTouchExplorationEnabled = false, mIsTouchExplorationEnabled = false, wasHighTextContrastEnabled = false, mIsHighTextContrastEnabled = false
                                                                           java.lang.Throwable: setStateLocked
                                                                               at android.view.accessibility.AccessibilityManager.setStateLocked(AccessibilityManager.java:553)
                                                                               at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636)
                                                                               at android.view.accessibility.AccessibilityManager.&lt;init&gt;(AccessibilityManager.java:226)
                                                                               at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206)
                                                                               at android.view.View.setFlags(View.java:9941)
                                                                               at android.view.ViewGroup.initViewGroup(ViewGroup.java:536)
                                                                               at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:525)
                                                                               at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:520)
                                                                               at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:516)
                                                                               at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:512)
                                                                               at android.widget.FrameLayout.&lt;init&gt;(FrameLayout.java:119)
                                                                               at com.android.internal.policy.impl.PhoneWindow$DecorView.&lt;init&gt;(PhoneWindow.java:2346)
                                                                               at com.android.internal.policy.impl.PhoneWindow.generateDecor(PhoneWindow.java:3643)
                                                                               at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:4036)
                                                                               at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:2057)
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:363)
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:277)
                                                                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                               at com.vyshnav.trainname.MainActivity.onCreate(**MainActivity.java:34**)
                                                                               at android.app.Activity.performCreate(Activity.java:6142)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1115)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2528)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656)
                                                                               at android.app.ActivityThread.access$800(ActivityThread.java:178)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                               at android.os.Looper.loop(Looper.java:194)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5691)
                                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:372)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>08-16 16:23:25.962 13558-13603/com.vyshnav.trainname E/GED: Failed to get GED Log Buf, err(0)
  </code></pre>