Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a send post to server method:</p> <pre><code> public String sendPostRequest(String url) { String result = null; URI wrapperUrl; try { wrapperUrl = new URI(url); HttpParams httpParameters = new BasicHttpParams(); int timeoutConnection = 20000; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); // Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data. int timeoutSocket = 20000; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); HttpPost post = new HttpPost(wrapperUrl); post.setParams(httpParameters); HttpResponse response = getDefaultClient().execute(post); HttpEntity responseEntity = response.getEntity(); String result = EntityUtils.toString(responseEntity); responseEntity.consumeContent(); result = new JSONObject(jsonResultString); } catch (URISyntaxException e) { Logger.debug(TAG, "Exception: " + e.toString()); e.printStackTrace(); } catch (ClientProtocolException e) { Logger.debug(TAG, "Exception: " + e.toString()); e.printStackTrace(); } catch (IOException e) { Logger.debug(TAG, "Exception: " + e.toString()); e.printStackTrace(); } return result; } </code></pre> <p>Reminder, use it in a work thread:</p> <pre><code> private void registerButtonListenersAndSetDefaultText() { mConfirmButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { saveState(); sendQuestToServer(); setResult(RESULT_OK); Toast.makeText(ProjectEditActivity.this, getString(R.string.task_saved_message), Toast.LENGTH_SHORT).show(); finish(); } }); } private void sendQuestToServer() { new Thread(new Runnale() { @Override void run() { String url = yourServerUrl + youreditText.getText.toString(); sendQuestToServer(url); } }).start(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload