У меня есть URL-адрес, подобный этому
http://182.72.198.001:8080/MyLogin/login/xxxxxx/yyyyyy
userName : xxxxxx
password : yyyyyy
Я использую модификацию, чтобы получить вышеуказанный URL-адрес, но он возвращает значение null, мой класс модернизации -
public class ApiClient {
public static Retrofit retrofit = null;
public static Retrofit getApiCLient() {
if (retrofit == null) {
retrofit = new Retrofit.Builder().baseUrl("http://182.72.198.001:8080/MyLogin/").addConverterFactory
(GsonConverterFactory.create()).build();
}
return retrofit;
}
}
, а класс myInterface -
public interface MyInterface {
@GET("login/")
Call<ResponseBody> LoginValidation(@Query("userName") String username, @Query("password") String password);
}
Мой основной класс
MyInterface loginInterface;
loginInterface = ApiClient.getApiCLient().create(MyInterface.class);
private void LoginUser()
{
final String usedrname = username1.getText().toString();
final String password = password1.getText().toString();
Call<ResponseBody> call = loginInterface.LoginValidation(usedrname,password);
Log.i("Tag","Interface" + usedrname+password);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.i("Tag","Respose" + response.body()); // this body returns null
Toast.makeText(getApplicationContext(), "Thank You!", Toast.LENGTH_SHORT).show();
editor.putString("username",usedrname);
editor.putString("password",password);
editor.putBoolean("isLoginKey",true);
editor.commit();
Intent i=new Intent(MainActivity.this,Navigation.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getApplicationContext(),"Username or password Mismatch",Toast.LENGTH_LONG).show();
}
});
}
Как я могу решить эту проблему, если я что-то не так сделал в этом коде?