【问题标题】:Unexpected response code 200意外响应代码 200
【发布时间】:2018-05-16 06:33:22
【问题描述】:

12-02 12:26:58.984 4028-4069/com.example.sainathpawar.volleyimage E/Volley:[162] BasicNetwork.performRequest:意外响应 http://lorempixel.com/600/400/city/ 12-02 12:26:58.985 的代码 200 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);
            }
        });
    }

    }

【问题讨论】:

  • 你能详细说明你得到这个结果的情况
  • 我创建了一个单例类,并将该单例类调用到我的主 Activity 中并向其传递了一个请求

标签: android api android-volley


【解决方案1】:

我通过将域更改为真实IP地址来解决它:

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

【讨论】:

    【解决方案2】:
    <?php
    
        header('Content-type:application/json;charset=utf-8');
        ...
        ...
        ...
        ...
        ?> 
    

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

    【讨论】:

    • 您是否也有理由这样做会有所帮助?
    猜你喜欢
    • 2014-09-21
    • 2017-07-24
    • 2019-12-25
    • 2019-01-21
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多