I'm a little disappointed and there has been a problem with me. I am trying to send all the user inputs through the REST request placed on the server. In this way the request appears on the Jason object server:
{ID: "123", text: "My name is Peter ..., age": 15, name: "Peter" Hobby: "ID:": "basketball";}, gender: true, version: 1}: "ID:", "hobbie_id", "id": "id": "football",}, id ": 213, hobbie_id" I have a class that has an internal class that extends from AsyncTask to handle server communication in the background:
public class MyActivity activity Enhances {Private Sector PutServiceTask asyncTask Expands & lt; String, integer, string & gt; {@Override Protected void onPreExecute () {// show dialog box} @ override protected string doInBackground (string ... url) {string URL = url [0]; String result = ""; HttpResponse response = doResponse (url); If (response == zero) {return result; } Return results; Private HTTPPassation DOSSpons (String URL) {HTTP Client http Client = New Default HTTP Client (); Hppit httpput = new htmlpit (url); HttpResponse response = null; // Add parameter {response = httpclient.execute (httpput); Threaded Positions = Response .getStatusLine (); Int statusCode = statusLine.getStatusCode (); If (statusCode == HttpStatus.SC_OK) {// 200 httpput.addHeader ("Content-Type", "App / JS"); String = New String Entity (Parameters.Stosting ()); Httpput.setEntity (se); HttpEntity unit = response.getEntity (); } Else {System.out.println (response.getStatusLine (). GetReasonPhrase ()); }} Hold (Exception E) {// TODO Automatic Holding Block e.printStackTrace (); } Return response; }}}} And the question is how can onPostExecute put it on the server in Methode. These are my user input that I get from EditText and gets transformed into a string:
private string string; // age string name string; // personal string of name of the person named hobby; // Private name of the hobby string text string; // text The other thing is that the id is it is correct that the server creates the ID, right?
I hope someone can help me in this matter!
Thanks in advance.
Well, handling it yourself is very complicated, this library has more clean API and type- Take a look with the secure data.
Here is an easy-to-use example
html http = httpfcc. (Context); Http.post ("http://example.com/users"). Data (New User ("John") Execute (); or more complex with callback
html ht = httpfcc (Context); Http.post ("http://example.com/users"). Data (New User ("John") Override public zero error (string message, HTTPRPS response response) {} Override public recordable failure (NetworkIer error) Override public zero success (zero dislocation, HTTPRPSPage response) {} Hendler (New Response Handler) } {} @ Override Public Veloid Full () {}}). carry about (); This is new, but looks very promising.
No comments:
Post a Comment