Created
January 25, 2019 11:29
-
-
Save fevziomurtekin/84c43921a75b4870c5133abe99e7b0db to your computer and use it in GitHub Desktop.
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
class RequestTask : AsyncTask<Void, Void, DetectIntentResponse> { | |
var activity: Activity? = null | |
private var session: SessionName? = null | |
private var sessionsClient: SessionsClient? = null | |
private var queryInput: QueryInput? = null | |
constructor(activity: Activity,session:SessionName,sessionsClient: SessionsClient,queryInput: QueryInput){ | |
this.activity=activity | |
this.session=session | |
this.queryInput=queryInput | |
this.sessionsClient=sessionsClient | |
} | |
override fun doInBackground(vararg params: Void?): DetectIntentResponse? { | |
try { | |
val detectIntentRequest = DetectIntentRequest.newBuilder() | |
.setSession(session.toString()) | |
.setQueryInput(queryInput) | |
.build() | |
return sessionsClient?.detectIntent(detectIntentRequest) | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} | |
return null | |
} | |
override fun onPostExecute(result: DetectIntentResponse?) { | |
(activity as MainActivity).onResult(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment