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(), "查詢結(jié)果成功", 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;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者