dialogflow-android-client icon indicating copy to clipboard operation
dialogflow-android-client copied to clipboard

SessionID

Open pcacermo opened this issue 8 years ago • 1 comments

It is not possible to put own sessionid. How can? i try with a java sdk and not found sessionid-branche thanks

jose patricio

pcacermo avatar Aug 23 '17 21:08 pcacermo

@pcarermo Im late to the answer, but if you look at ai.api.android.SessionIdStorage You can see that it use sharedPref to store the data of Session ID:

If you edit the preferences using the same keys, you can use the value that you want.

You can use the code bellow, it add new random value at the begining of activity, to start new fresh session each time

    val pref_name = "APIAI_preferences"
    val SESSION_ID = "sessionId"
    randomUUID = UUID.randomUUID().toString()

    val sharedPreferences = getSharedPreferences(pref_name, Context.MODE_PRIVATE)
    val editor = sharedPreferences.edit()
    editor.putString(SESSION_ID, randomUUID)
    editor.apply()

meleastur avatar Jun 21 '19 08:06 meleastur