美文网首页
安卓开发网络测试(markedown)

安卓开发网络测试(markedown)

作者: Kingcee | 来源:发表于2016-11-16 14:59 被阅读16次
    String url = "http://apis.baidu.com/apistore/mobilenumber/mobilenumber?phone=13*****7*57";
    JsonObjectRequest request = new JsonObjectRequest(Method.GET, url, null, new Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            Log.d(TAG, "查询成功:" + response);
            Toast.makeText(getApplicationContext(), "查询结果成功", Toast.LENGTH_SHORT).show();
        }
    }, new ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "查询失败:" + error);
            Toast.makeText(getApplicationContext(), "查询失败", Toast.LENGTH_SHORT).show();
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("apikey", "[baidukey]");
            return headers;
        }
    };
    request.setTag("phoneGet");
    UserLocalApplication.getHttpQueue().add(request);
    
    public class UserLocalApplication extends Application  {
        public static RequestQueue requestQueue;//
    
        @Override
        public void onCreate() {
            super.onCreate();
            requestQueue = Volley.newRequestQueue(getApplicationContext());
        }
    
        public  static  RequestQueue getHttpQueue(){
            return requestQueue;
        }
    }
    

    相关文章

      网友评论

          本文标题:安卓开发网络测试(markedown)

          本文链接:https://www.haomeiwen.com/subject/zsdrpttx.html