英文:
Toast Message is not displayed?
问题
我正在尝试赋予一个应用蓝牙连接功能。当蓝牙被打开时,它并没有显示弹出消息。
如果 (!bluetoothAdapter.isEnabled()) {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1);
Toast.makeText(HeartRate.this, "已打开", Toast.LENGTH_LONG);
}
<details>
<summary>英文:</summary>
I am trying to give an application, Bluetooth connectivity when the Bluetooth is turned on it does not show the toast message
if (!bluetoothAdapter.isEnabled()) {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1);
Toast.makeText(HeartRate.this, "Turned on", Toast.LENGTH_LONG);
}
</details>
# 答案1
**得分**: 1
如果您忘记了某些东西
```java
if (!bluetoothAdapter.isEnabled()) {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1);
//.show happens a lot of times to me
Toast.makeText(HeartRate.this, "已打开", Toast.LENGTH_LONG).show();
}
英文:
you forgot something
if (!bluetoothAdapter.isEnabled()) {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1);
//.show happens a lot of times to me
Toast.makeText(HeartRate.this, "Turned on", Toast.LENGTH_LONG).show();
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论