How to pass the value into php from android?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 13:20:32

You can use this by POST or GET

    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("questionid", questionid));

    try {
        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
        HttpConnectionParams.setSoTimeout(httpParameters, 10000);
        HttpClient httpClientpost = new DefaultHttpClient(httpParameters);

        //HttpGet post = new HttpGet(url_request);
        HttpPost post = new HttpPost(url_request);

        UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,
                HTTP.UTF_8);
        post.setEntity(ent);


        HttpResponse responsePOST = httpClientpost.execute(post);
        HttpEntity resEntity = responsePOST.getEntity();
        String getresponse = EntityUtils.toString(resEntity); //Response from the server
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!