Guest User

Untitled

a guest
May 27th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class DoTextRequestTask extends AsyncTask<String, Void, AIResponse> {
  2. private Exception exception = null;
  3. protected AIResponse doInBackground(String... text) {
  4. AIResponse resp = null;
  5. try {
  6. final AIConfiguration config = new AIConfiguration("6d138f04d3dc45b1bc15f81741b05da1",
  7. AIConfiguration.SupportedLanguages.English,
  8. AIConfiguration.RecognitionEngine.System);
  9. resp = AIService.getService(this, config).textRequest(text[0], new RequestExtras());
  10. // might depend on you implementation ; find out how to
  11. // retrieve the AIService instance and replace "aiDialog.getAIService()"
  12. } catch (Exception e) {
  13. this.exception = e;
  14. }
  15. return resp;
  16. }
  17. protected void onPostExecute(AIResponse response) {
  18. if (this.exception == null) {
  19. // todo : handle the exception
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment