 |
ผมได้ทำการอ่านค่า QR Code จากนั้นเก็บค่าไว้ parameter ส่วนที่ highlight คือ parameter ผมติดตรงที่นำพรารามิเตอร์ส่งในรูป GET ผ่านตัวแปร x และส่งค่าไปที่เว็บ http://test/reader/qrcode?=x ทันที ช่วยแนะนำส่วนนี้ |
|
 |
|
|
 |
 |
|
Code (Android-Java)
private void postData(final String param, final TextView tv) {
RequestQueue rq = Volley.newRequestQueue(this);
StringRequest postReq = new StringRequest(Request.Method.POST,
"https://your URL",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
tv.setText(response); // We set the response data in the
// TextView
Toast.makeText(getApplicationContext(), "Response"+response,Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
System.out.println("Error [" + error + "]");
Toast.makeText(getApplicationContext(), "No Internet!!!", Toast.LENGTH_LONG).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("your key", "value");
params.put("any callback methods", "value");
params.put("any types", "value");
return params;
}
};
rq.add(postReq);
Rahul@SO
|
 |
 |
 |
 |
Date :
2020-06-29 17:26:33 |
By :
PhrayaDev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|