标签:vol 数据 ESS str 错误 service ide run res
时间紧张,直接上代码
public class MainActivity extends AppCompatActivity { private RequestQueue queues ; String str; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); queues = Volley.newRequestQueue(this); String getcode = getcode(); System.out.println(getcode+"得到响应"); } public String getcode() { new Thread() { @Override public void run() { super.run(); StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://4444444444444/api/services/app/AppUser/Registe", new Response.Listener<String>() { @Override public void onResponse(String response) { System.out.println("响应" + response); str = response; handler.sendEmptyMessage(1); Log.d("TAG", response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("TAG", error.getMessage(), error); System.out.println("错误" + error); } }) { @Override protected Map<String, String> getParams() throws AuthFailureError { // 请求参数 Map<String, String> map = new HashMap<String, String>(); //new 一个Map 参数放到Map中 map.put("Mobile", "15837645260"); map.put("UserPwd", "1234567"); System.out.println("添加参数"); return map; } }; queues.add(stringRequest); System.out.println("输出str是:" + str); } }.start(); return str; } Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); System.out.println("得到数据"+str); } }; }
implementation ‘org.xutils:xutils:3.5.0‘
标签:vol 数据 ESS str 错误 service ide run res
原文地址:https://www.cnblogs.com/Ocean123123/p/11153046.html