串口数据处理
This commit is contained in:
@@ -9,6 +9,7 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
@@ -37,6 +38,7 @@ import kotlin.random.Random
|
||||
class ShelfActivity : BaseActivity() {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ShelfActivity"
|
||||
const val SHELF_MODEL = "shelfModel"
|
||||
const val RECEIVER_DEVICE_INFO = "receiverDeviceInfo"
|
||||
const val SHELF_WEIGHT = "shelfWeight"
|
||||
@@ -119,6 +121,8 @@ class ShelfActivity : BaseActivity() {
|
||||
private val receiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
intent?.let {
|
||||
val data = it.getStringExtra(RECEIVER_DEVICE_INFO)
|
||||
Log.d(TAG, "onReceive: $data")
|
||||
realWeight = it.getIntExtra(SHELF_WEIGHT, 0)
|
||||
binding.tvFoodWeight.text = "${realWeight}克"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user