Last active
October 13, 2015 18:57
-
-
Save ismaelc/4240703 to your computer and use it in GitHub Desktop.
Mashape Android Async example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void sendMessage(View view) { | |
EditText editText = (EditText) findViewById(R.id.edit_message); | |
String message = editText.getText().toString(); | |
new CallMashapeAsync().execute(message); | |
} | |
private class CallMashapeAsync extends AsyncTask<String, Integer, MashapeResponse<JSONObject>> { | |
protected MashapeResponse<JSONObject> doInBackground(String... msg) { | |
QuestionAnswering client = new QuestionAnswering("MASHAPE_KEY"); | |
return client.answerAQuestion(msg[0]); | |
} | |
protected void onProgressUpdate(Integer...integers) { | |
} | |
protected void onPostExecute(MashapeResponse<JSONObject> response) { | |
String answer = response.getBody().toString(); | |
TextView txtView = (TextView) findViewById(R.id.textView1); | |
txtView.setText(answer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment