在我尝试使用getheader()方法时,android AIDE IDE android显示错误

时间:2020-12-22 16:30:40

android volly showing error when I try to use getheader() method. I was trying to do a simple task which needs some networking with volly I'm using Aide ide on my android tablet. I couldn't figure out how to fix this Error

当我尝试使用getheader()方法时,android volly显示错误。我试图做一个简单的任务,需要一些网络,我在Android平板电脑上使用Aide ide。我无法弄清楚如何修复此错误

  1. method onResponse does't override method from its super class
  2. 方法onResponse不会覆盖超类的方法

  3. method onErrorResponse does't override method from its super class
  4. 方法onErrorResponse不会覆盖其超类的方法

//My code

private void jsonObjectMethod(){
    String url = "www.example.com"; 
    // enter url here
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null,
    new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            // Handle your response
        }

    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            // Handle your error
        }

    }){
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError{ 
            Map<String, String>  params = new HashMap<String, String>();  
            params.put("Accept-Language", "en");

            return params;  
        }
    };



    MainApplication.getInstance(this).addToRequestQueue(jsonObjectRequest);
}

Screenshot of the error

错误的屏幕截图

1 个解决方案

#1


1  

There are some methods you haven't overridden. WHen you extend or implement a class, there are some classes you have to override. With classes you have to override abstract methods, and with interfaces you have to override all methods. So the error is because there are some methods you haven't overridden and in this case you are missing onResponse and onErrorResponse. I'm not sure if it is those two, but it looks like that from the poorly formatted error in your question.

有些方法没有被覆盖。当你扩展或实现一个类时,你必须覆盖一些类。对于类,您必须覆盖抽象方法,并且使用接口必须覆盖所有方法。所以错误是因为有些方法没有被覆盖,在这种情况下你缺少onResponse和onErrorResponse。我不确定它是否是那两个,但它看起来像你问题中格式错误的错误。

And if you ask a question in the future, don't provide a screenshot. Format it and add it into the question, don't mash it into a single line

如果您将来提出问题,请不要提供截图。对其进行格式化并将其添加到问题中,不要将其混合成一行

#1


1  

There are some methods you haven't overridden. WHen you extend or implement a class, there are some classes you have to override. With classes you have to override abstract methods, and with interfaces you have to override all methods. So the error is because there are some methods you haven't overridden and in this case you are missing onResponse and onErrorResponse. I'm not sure if it is those two, but it looks like that from the poorly formatted error in your question.

有些方法没有被覆盖。当你扩展或实现一个类时,你必须覆盖一些类。对于类,您必须覆盖抽象方法,并且使用接口必须覆盖所有方法。所以错误是因为有些方法没有被覆盖,在这种情况下你缺少onResponse和onErrorResponse。我不确定它是否是那两个,但它看起来像你问题中格式错误的错误。

And if you ask a question in the future, don't provide a screenshot. Format it and add it into the question, don't mash it into a single line

如果您将来提出问题,请不要提供截图。对其进行格式化并将其添加到问题中,不要将其混合成一行