From 8c69444d8129193511eca990b6d97be5c36232ea Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期三, 25 十一月 2020 15:58:46 +0800 Subject: [PATCH] xxx --- app/src/main/java/safeluck/drive/evaluation/MainActivity.java | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java index 5e5bc31..ed7a761 100644 --- a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java +++ b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java @@ -93,6 +93,7 @@ private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); private AuthMapViewmodel authMapViewmodel; + String des ="钃濈墮鍏抽棴"; private ICEventListener icEventListener = new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { @@ -117,10 +118,12 @@ if (msgCode == Constant.ID_SM_BLUETOOTH_BRIEF){ if (tv_ble_status != null){ try { - JSONObject jsonObject = new JSONObject((String) obj); - int bleStatus = jsonObject.getInt("bluetooth_stauts"); - String mac = jsonObject.getString("bluetooth_addr"); - String des ="钃濈墮鍏抽棴"; + String str = (String) obj; + Log.i(TAG,"shou=="+str); + JSONObject jsonObject = new JSONObject(str); + int bleStatus = jsonObject.getInt("bluetooth_status"); + + switch (bleStatus){ case 0: des ="钃濈墮鍏抽棴"; @@ -134,10 +137,17 @@ case 3: authMapViewmodel.setAuthValue(3); des ="钃濈墮杩炴帴"; + String mac = jsonObject.getString("bluetooth_addr"); SPUtils.put(getApplicationContext(),SPUtils.BLUETOOTH_MAC,mac); break; } - tv_ble_status.setText(des); + tv_ble_status.post(new Runnable() { + @Override + public void run() { + tv_ble_status.setText(des); + } + }); + } catch (JSONException e) { e.printStackTrace(); } -- Gitblit v1.8.0