Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DoTextRequestTask extends AsyncTask<String, Void, AIResponse> {
- private Exception exception = null;
- protected AIResponse doInBackground(String... text) {
- AIResponse resp = null;
- try {
- final AIConfiguration config = new AIConfiguration("6d138f04d3dc45b1bc15f81741b05da1",
- AIConfiguration.SupportedLanguages.English,
- AIConfiguration.RecognitionEngine.System);
- resp = AIService.getService(this, config).textRequest(text[0], new RequestExtras());
- // might depend on you implementation ; find out how to
- // retrieve the AIService instance and replace "aiDialog.getAIService()"
- } catch (Exception e) {
- this.exception = e;
- }
- return resp;
- }
- protected void onPostExecute(AIResponse response) {
- if (this.exception == null) {
- // todo : handle the exception
- }
- }
- }
Add Comment
Please, Sign In to add comment