I've an activity where I receive data via BLE and display it (ControlActivity). There's a second activity where I want to display the received data in a different way (OnlineActivity).
In ControlActivity there's a method that get's called when data is received via BLE:
private fun onNotificationReceived(bytes: ByteArray){
if(bytes[0] == 0x01){
//handle with ControlActivity
}
else if(bytes[0] == 0x02){
//handle with OnlineActivity
//startedinstanceofOnlineActivity?.handleData(bytes)
}
}
Data comes in about every second periodically.
There's a button in the ControlActivity which should start the OnlineActivity:
control_online.setOnClickListener {
val intent = Intent(this,OnlineActivity::class.java)
startActivity(intent)
}
To call a method of OnlineActivity from ControlActivity I would need the Instance of OnlineActivity that is created/started here. The method in OnlineActivity should change a few textViews in OnlineActivity based on the data from ControlActivity.
onNotificationReceived gets also called continuously, when OnlineActivity is active.
I just need a "quick and dirty"-solution for my problem, as this is just a very basic test-app for myself. I don't want to invest too much time with TabViews, etc.. I'm just an embedded software-engineer who wants to display his received data in any way for testing purposes. I never developed an app before.