English 中文(简体)
http://www.un.org。
原标题:Android http post not sending data

第一,获得《地位法》200 的Im。 在文件S.C.S.A.S.A.中,Im只是把什么寄给服务器(在我尝试和欺骗时)。 利用var_dump$_POST或_REquestST I获得空白电子邮件。 如果我用美元开张,我会得到一些数据,如吉大港山区。 USER_AGENT :ache-HttpClient/UNAVAILABLE (java 1.4) and CONTENT_LENGTH : 9

I don t understand why there s no post data? I m new to android, I m literally learning as I go.

HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(dest_url);
    //httppost.setHeader("Accept", "application/json");
    //httppost.setHeader("Content-type", "application/json");

//JSONObject json = new JSONObject();

        // Add your data
        //json.put("action", "login");
        //json.put("username", "kermit");
        //json.put("password", "123456");

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    //nameValuePairs.add(new BasicNameValuePair("myjson", json.toString()));
    nameValuePairs.add(new BasicNameValuePair("plswork", "hi"));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));

    //StringEntity str_json = new StringEntity(json.toString());

    //httppost.setEntity(str_json);
    HttpResponse response;

    response = httpclient.execute(httppost);

我的言行如下:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

这些是我的进口;

import java.io.IOException;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
最佳回答

很可能与你有某种关系。

httppost.setHeader("Content-type", "application/json");

www.un.org/Depts/DGACM/index_spanish.htm 提交《吉大港山区行动计划》并非正常内容。 认为你不是真的寄售 j子,而是标准业务主管实体(名称String=价值String),试图改变这一方向,

httppost.setHeader("Content-Type", "application/x-www-form-urlencoded")

并看这一问题是否定型。 更糟糕的是,将它全部移走。

我在我看来使用这一法典,它非常出色:

HttpPost httppost = new HttpPost(SERVER_URL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("REQUEST", req));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
HttpResponse response = httpclient.execute(httppost);

本案的答复是text/xml,但本表事项。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签