Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

issue in configurator file

$
0
0

I'd like to implement a configurator for this code (below). I need to be able to temporarily store and modify three parameters (deviceId, userId, sessionId). As I understand it, this can be done using a singleton, as well as using Preferences DataStore and Proto DataStore. Can you tell me how to implement this with my code? (I'm new to kotlin and I don't understand many things, and I hope for your help)

    class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        setContentView(R.layout.activity_main)    }    val psInterceptor = PSInterceptor("device1","user1","session1"    )    val client = OkHttpClient.Builder()        .addInterceptor(psInterceptor)        .build()    fun sendMessage(view: View) {        val request = Request.Builder()            .url("https://catfact.ninja/fact")            .addHeader("Example", "Header")            .build()        try {            lifecycleScope.launch(Dispatchers.IO) {                val response = client.newCall(request).execute()            }        } catch (e: Exception) {            println(e)        }    }}

Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>