翻新。应用程序保持停止

问题描述 投票:0回答:1

如果您在请求中指定了URL路径,则在调用与api的连接时,应用程序将关闭。如果您编写时不带参数,则应用程序将发送请求,而我会得到响应。可能是什么原因?

URL路径:{phone}

public interface ApiInterface {
    @GET("Register?app=CxTaxiWebAPI&phone={phone}")
    Call<List<PhoneNumber>> registration(@Path("phone") String phoneNumber);
}

依赖关系:

    implementation 'com.google.code.gson:gson:2.6.2'
    implementation 'com.squareup.retrofit2:retrofit:2.0.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'

请求:

public void EnterCodeOnClick(View view) {

apiInterface = ApiClient.getClient().create(ApiInterface.class);

Call<List<PhoneNumber>> call = apiInterface.registration("34");

call.enqueue(new Callback<List<PhoneNumber>>() {
    @Override
    public void onResponse(Call<List<PhoneNumber>> call, Response<List<PhoneNumber>> response) {
        Log.e(TAG, "onResponse: " +  response.body());
    }

    @Override
    public void onFailure(Call<List<PhoneNumber>> call, Throwable t) {
        Log.e(TAG, "onFailure: " + t.getLocalizedMessage() );
    }
});
android retrofit
1个回答
0
投票

尝试一下:

@GET("Register?app=CxTaxiWebAPI")
  Call<List<PhoneNumber>> registration(@Query("phone") String phone);
© www.soinside.com 2019 - 2024. All rights reserved.