【问题标题】:how to send large string to server in android?如何在android中将大字符串发送到服务器?
【发布时间】:2014-08-17 04:17:23
【问题描述】:

我想从android向服务器发送大字符串,我可以用这个方法发送小字符串

        InputStream is;
        String name = "Name";
        String str = "LargeString";

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

        nameValuePairs.add(new BasicNameValuePair("name", name));
        nameValuePairs.add(new BasicNameValuePair("encoded", str));

        try {

            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new
            HttpPost("http://192.168.1.101/test/insert.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = (InputStream) entity.getContent();


        } catch (Exception e) {

            Log.e("log_tag", "Error in http connection " + e.toString());

        }

使用此代码,我可以发送小字符串但不能发送大字符串。 请帮帮我。

谢谢。

【问题讨论】:

  • 在帖子中你可以发送大字符串,你有什么错误吗?
  • 什么是错误,显示logcat信息
  • 此链接将帮助您 [如何使用 Android 通过 Request 发送 JSON 对象?] stackoverflow.com/questions/3027066/…
  • 没有错误显示,但是当我发送小字符串时它可以工作,但大字符串不起作用
  • 我尝试发送视频编码字符串

标签: php android http-post


【解决方案1】:

使用HttpUrlConnection

您可以参考here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 2011-09-16
    • 1970-01-01
    • 2014-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多