debug: 解绑加Toast调试,确认消息是否收到和导航是否成功
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -137,14 +137,22 @@ class MainActivity : AppCompatActivity() {
|
|||||||
3 -> {
|
3 -> {
|
||||||
// 解绑 → 清除数据 → 跳绑定页(从任何页面都能跳)
|
// 解绑 → 清除数据 → 跳绑定页(从任何页面都能跳)
|
||||||
Timber.d("MainActivity: 收到解绑消息")
|
Timber.d("MainActivity: 收到解绑消息")
|
||||||
|
android.widget.Toast.makeText(this@MainActivity, "收到解绑消息", android.widget.Toast.LENGTH_SHORT).show()
|
||||||
bluetoothScanManager.stop()
|
bluetoothScanManager.stop()
|
||||||
userPrefs.clear()
|
userPrefs.clear()
|
||||||
try {
|
try {
|
||||||
val navHost = supportFragmentManager
|
val navHost = supportFragmentManager
|
||||||
.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
.findFragmentById(R.id.nav_host_fragment) as? NavHostFragment
|
||||||
|
if (navHost != null) {
|
||||||
navHost.navController.navigate(R.id.action_global_to_bind)
|
navHost.navController.navigate(R.id.action_global_to_bind)
|
||||||
|
Timber.d("MainActivity: 解绑导航成功")
|
||||||
|
} else {
|
||||||
|
Timber.e("MainActivity: NavHostFragment 为 null")
|
||||||
|
android.widget.Toast.makeText(this@MainActivity, "导航失败:NavHost为空", android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "MainActivity: 解绑导航异常")
|
Timber.e(e, "MainActivity: 解绑导航异常")
|
||||||
|
android.widget.Toast.makeText(this@MainActivity, "导航异常:${e.message}", android.widget.Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user