Toast消息未显示?

huangapple go评论77阅读模式
英文:

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, &quot;Turned on&quot;, 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, &quot;Turned on&quot;, Toast.LENGTH_LONG).show();
            }

huangapple
  • 本文由 发表于 2020年5月5日 22:11:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/61615146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定