I know a few people have asked this question before, but I have tried those answers. I am new to Android. Everything looks good, but I don't get why I am getting an empty object? Anyone can Guide me about that?
Interface:
public interface CryptoAPI {
@GET("ActivityForTestingPurposeOnly/")
io.reactivex.Observable<List<Stream>> getData(@Query("Row") String Row,
@Query("Top") String Top,
@Query("AppID") String appid);
This is my retrofit adapter:
public class RetrofitAdapter {
private String BASE_URL = "http://m.ilmkidunya.com/api/sectionactivity/sectionactivity.asmx/"
public static CryptoAPI newAPICreator() {
final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
final OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build();
return retrofit.create(CryptoAPI.class);
}
}
}
Finally, the method where I am getting the response:
public void getStreams(){
CryptoAPI.RetrofitAdapter.newAPICreator()
.getData("0", "20", "73")
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Stream>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Stream model) {
arrayList.add(model);
Toast.makeText(getApplicationContext(),
"Size: " + arrayList.size(),
Toast.LENGTH_SHORT);
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onComplete() {
}
});
}
> here is my
@SerializedName("ID")
@Expose
private Integer iD;
@SerializedName("Rating")
@Expose
private Integer rating;
@SerializedName("SectionID")
@Expose
private Integer sectionID;
@SerializedName("ContentID")
@Expose
private Integer contentID;