意外的响应代码200

时间:2017-12-02 07:04:03

标签: android api android-volley

  

12-02 12:26:58.984 4028-4069 / com.example.sainathpawar.volleyimage   E / Volley: [162] BasicNetwork.performRequest:意外的响应   代码200 http://lorempixel.com/600/400/city/ 12-02 12:26:58.985   4028-4028 / com.example.sainathpawar.volleyimage I /错误:错误12-02   12:27:00.262 4028-4068 / com.example.sainathpawar.volleyimage E / Volley:   [161] BasicNetwork.performRequest:意外的响应代码200   http://lorempixel.com/600/400/city/ 12-02 12:27:00.264   4028-4028 / com.example.sainathpawar.volleyimage I /错误:错误

获取上述错误此错误的含义是什么?我正在尝试从API“http://lorempixel.com/600/400/city/”获取图片“是否与权限相关?

以下是我收到错误的代码。

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final String myURL = "http://lorempixel.com/600/400/city/";

        Button myButton = findViewById(R.id.button);
        ImageView imageView = findViewById(R.id.imageView);
        myButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ImageRequest imageRequest = new ImageRequest(myURL,
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {

                            }
                        }, 0, 0, null, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.i("Error","Error");
                    }
                });
                MySingleton.getmInstance(MainActivity.this).addToRequest(imageRequest);
            }
        });
    }

    }

2 个答案:

答案 0 :(得分:0)

我通过将域名更改为真实IP地址来解决此问题:

var socket = io.connect('http://182.92.79.215:3007');

答案 1 :(得分:0)

<?php

    header('Content-type:application/json;charset=utf-8');
    ...
    ...
    ...
    ...
    ?> 

在您的php代码中添加此代码,也许添加这段代码可以帮助您解决此问题...:)