私は改造2を使用して私のサーバにapi呼び出しを行いますが、api呼び出しをしようとすると突っ込んでしまいます。これは私のコードです改造がAPI呼び出しをしていない
public interface GOTApi {
@GET("characters.json")
Call<GOTCharacterResponse> getCharacters();
}
データ
public class GOTCharacterResponse {
List<GOTCharacter> characters;
}
作るために私のクラスを取得するための中級クラスのAPIコール
public class GOTService {
public static final String BASE_URL = "https://project-8424324399725905479.firebaseio.com/";
public static GOTApi getGOTApi(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(GOTApi.class);
}
public static void getCharacters(){
getGOTApi().getCharacters().enqueue(new Callback<GOTCharacterResponse>() {
@Override
public void onResponse(Call<GOTCharacterResponse> call, Response<GOTCharacterResponse> response) {
if(response.isSuccessful()){
}
}
@Override
public void onFailure(Call<GOTCharacterResponse> call, Throwable t) {
int a = 0;
}
});
}
}
これらは私が
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
を使用しているライブラリがあります
いつも私はくっついてしまうn getCharacters()メソッドもちろん、私はMainfestに設定されたインターネットの許可を持っています。
「突っ込まれる」とはどういう意味ですか?クラッシュ?または? –
いいえ、クラッシュしない、プロセスが続行されない、logcatで警告またはエラーが表示されない – aloj