Skip to content

Instantly share code, notes, and snippets.

@fevziomurtekin
Created January 25, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fevziomurtekin/84c43921a75b4870c5133abe99e7b0db to your computer and use it in GitHub Desktop.
Save fevziomurtekin/84c43921a75b4870c5133abe99e7b0db to your computer and use it in GitHub Desktop.
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