I want to fetch JSON string array from server using Retrofit. The JSON array is like this.
["A","B","C"]
Here is the code I made .
MainActivity.class
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url="http://proverbs-app.antjan.us";
RestAdapter restAdapter;
restAdapter = new RestAdapter.Builder()
.setEndpoint(url)
.build();
Service service=restAdapter.create(Service.class);
service.get(new Callback<List<String>>(){
@Override
public void failure(RetrofitError error) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
@Override
public void success(List<String> arg0, Response arg1) {
Toast.makeText(getApplicationContext(), arg0.toString(), Toast.LENGTH_LONG).show();
}
});
}
}
Here is the Service.class
public interface Service {
@GET("/")
public void get(Callback<List<String>> callback);
}
It shows only "Error" Toast.
Am I something wrong with my codes. Please help me to fix it. I'm a beginner. So,please answer me in detail because I don't know much about it. Thanks in advance.
new RestAdapter.Builder().setLogLevel(RestAdapter.LogLevel.FULL)