改装件输入onFailure

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

我知道有很多类似的问题,但是自从一年多以前,这是一个-运行良好-应用程序,现在突然不起作用,因为Retrofit没有输入onResponse,但是它正在输入onFailure,这是一个令人惊讶的新问题,请提供任何评论的帮助

公共接口APIService {

@GET("pruebas/BDHacienda9.json")
Call<String> getMyTests();

}

http://www.coachingempresas.com/pruebas/BDHacienda9.json

如您所见,我发送了Json,因此您可以对其进行测试。这是DetailActivity中其余有意义的代码:

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();

    APIService service = retrofit.create(APIService.class);
    myData = service.getMyTests();




}

public void test (View v) {
    sendToTestActivity();

}



private void sendToTestActivity() {
    myData.enqueue(new Callback<String>() {
        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                jsonString = response.body().toString();
                //Log.i(">> jsonString", String.valueOf(jsonString));

                // Send bundle to TestActivity

                Intent intent = new Intent(getApplicationContext(), TestActivity.class);
                Bundle bundle = new Bundle();
                bundle.putInt("temaElegidoInt", temaElegidoInt);
                bundle.putString("jsonString", jsonString);
                intent.putExtras(bundle);
                startActivity(intent);

            }



        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            Log.e("call >>>>>>", "error");
        }
    });

}
android retrofit2
1个回答
0
投票

我认为我的http://中存在一个安全问题,因为Android9不允许使用,因此我需要一个https://,所以我将遵循以下建议:Android 8: Cleartext HTTP traffic not permitted

© www.soinside.com 2019 - 2024. All rights reserved.