0

So I'm developing an Android app (Java) that posts a JSON object to a web server. I've achieved this, but I'm battling to get the string value to display properly. Instead of the server receiving "6666666666666", it receives "Ljava.lang.String;@41108be0]". How on earth do I go about fixing this? Here's my code:

protected Boolean doInBackground(String... ID) {
HttpClient httpClient = new DefaultHttpClient();
Date dateTime = new Date();
string deviceID=null;
try {
HttpPost request = new HttpPost("http://192.168.1.89:80/");
JSONObject json = new JSONObject();
json.put("IDNo", ID.toString());
json.put("DTSent", dateTime);
json.put("DeviceID", deviceID);

StringEntity se = new StringEntity(json.toString(), "UTF-8");
se.setContentType("application/json; charset=UTF-8");
request.setEntity(se);
request.setHeader( "Content-Type", "application/json");
}

Please help.

KingMikel89
  • 45
  • 1
  • 4

2 Answers2

4

ID is a String-Array not just a string. the ... makes it an array. so either use ID[0] or remove the ... from the function declaration

x4rf41
  • 5,184
  • 2
  • 22
  • 33
1

You are passing in an array of strings (see the three dots?). Try using ID[0] instead.

Here is a useful post:

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75