###下準備
・Volleyを取り込む
・PermissionでINTERNETを許可
###コード
MyActivity.java
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
//queue
RequestQueue queue = Volley.newRequestQueue(this);
//url
final String url = "http://www.bluecode.jp/test/res.php";
//Request
StringRequest postRequest = new StringRequest(Request.Method.POST,url,
new Response.Listener<String>() {
@Override
public void onResponse(String s) {
Log.v("tama","RESPONSE=" + s);
}
},
new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error){
//error
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String,String>();
params.put("name","hoge");
params.put("age","44");
return params;
}
};
queue.add(postRequest);
}