英文:
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();
}
专注分享java语言的经验与见解,让所有开发者获益!
评论