Interface class:
interface MyCustomInterface {
fun get_msg( str: String)
}
SplashScreen Activity:
class SplashActivity : AppCompatActivity(),MyCustomInterface {
override fun get_msg(str: String) {
}
val socket=MysocketIO(this)
}
MySocketIO class where I added the data to interface from server:
class MysocketIO(var mainActivity: SplashActivity) : Thread() {
fun enable_data_event():Boolean {
try {
data_event_registered.set(true)
socket!!.on(this.data_event_id, object : Emitter.Listener {
override fun call(vararg args: Any) {
receive_data_queue.add(args[0] as String)
data_recieved.set(true)
mainActivity.get_msg(receive_data_queue.peek())
}
})
return true
}
catch (ex : java.lang.Exception){
ex.printStackTrace()
}
}
}
How to get data from SplashScreen to another activity?