2017-06-05 6 views
0

マイインターフェースエラーは、レトロフィット接続

@POST("/insert.php") 
void login(Callback<Response> callback); 

Javaコード

Retrofit adapter = new Retrofit.Builder() 
         .baseUrl(ROOT_URL) //Setting the Root URL 
         .addConverterFactory(GsonConverterFactory.create()) 
         .build(); //Finally building the adapter 

Register_Retrofit api = adapter.create(Register_Retrofit.class); 


api.login(new Callback<Response>() { 
    public void onResponse(Call<Response> call, Response<Response> response) { 

    } 

    public void onFailure(Call<Response> call, Throwable t) { 

    } 

}); 
+1

「エラー」を明確にすることはできますか? 「エラー」はどういう意味ですか?コンパイル時間?ランタイム?スタックトレース?あなたのコードが期待どおりに機能していないことだけですか?あなたは何をすることを期待していましたか? – Stultuske

+0

何が原因でしたか? –

答えて

0

あなたのloginメソッドの戻りのボイドを発生したので、あなたはこのように、それを定義する必要があります。

@POST("/insert.php") 
Call<Void> login(); 

その後、ログインメソッドを呼び出すには、これを試してください:

Retrofit adapter = new Retrofit.Builder() 
         .baseUrl(ROOT_URL) //Setting the Root URL 
         .addConverterFactory(GsonConverterFactory.create()) 
         .build(); //Finally building the adapter 

Register_Retrofit api = adapter.create(Register_Retrofit.class); 
Call<Void> loginCall = api.login(); 
loginCall.enqueue(new Callback<Void>() { 
    public void onResponse(Call<Void> call, Response<Void> response) { 
      ... 
    } 

    public void onFailure(Call<Void> call, Throwable t) { 
      ... 
    } 
});