android how to Send a String of data from an android mobile to server python what need to be modified in this android code
enter code here
public void appendText(View view){
Text.append( "\n In chat ");
try{
// while (true)
//{
sentence=inputfld.getText().toString();
// String sentence1=("hohohoh");
Text.append( "\n DataStream creating");
outToServer.writeBytes(sentence);
// outToServer.writeBytes(sentence1);
modifiedSentence = inFromServer.readLine();
Text.append(modifiedSentence);
inputfld.setText(null);
}
}
catch(Exception modifiedsentence){
Text.append("Exception");
}
}
RestClient client = new RestClient(webServiceUrl);
client.addBasicAuthentication(username, password);
try {
client.execute(RequestMethod.GET);
if (client.getResponseCode() != 200) {
//return server error
return client.getErrorMessage();
}
//return valid data
JSONObject jObj = new JSONObject(client.getResponse());
return jObj.toString();
} catch(Exception e) {
return e.toString();
}
So this to be added the Restclient is what i creat a new class for it ???
If your server is RESTful, you might try using HTTPclient to post the data to the server and read the response. If you use a REST abstraction layer like https://github.com/TylerSmithNet/RESTclient-Android (self promotion) then you can use the examples to get running in no time.