Tag: 蓝牙

消息没有收到蓝牙聊天。 我的处理程序是否坏了

我正在开发Android开发项目。 蓝牙的网站,它似乎是正确的发送消息,但没有收到他们。 过去,我试图创建另一个蓝牙应用程序,当连接到设备时,系统提示我确认连接,并显示PIN码。 在当前的应用程序工作时,我从来没有得到提示。 但是,它并没有出现任何exception情况,并且消息似乎正在发送。 这是我的Thread类用于管理连接: inner class ConnectedThread(val socket:BluetoothSocket, val socketType:String) : Thread(){ val inStream = socket.inputStream val outStream = socket.outputStream init { mState = STATE_CONNECTED } override fun run() { Log.i(TAG, “BEGIN mConnectedThread”) val buffer = ByteArray(1024) var bytes:Int while (mState == STATE_CONNECTED){ try { bytes = inStream.read(buffer) mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer) .sendToTarget() […]

Android – 正确的通知方式和服务

我正在开发一个Android应用程序,它必须通过蓝牙保持连接并监听来电,如果它在前台运行。 当我得到蓝牙连接时保持服务正常运行,并在断开连接时停止服务,从而能够正常工作。 Service : public class ConnectionService extends Service { private final int NOTIFICATION_ID = 327; @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } @Override public IBinder onBind(Intent intent) { throw new UnsupportedOperationException(“Not yet implemented”); } @Override public void onCreate() { //Creates notification Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent […]

如何创建BLE设备的模拟器通过蓝牙进行通信?

我正在创建一个应用程序,我需要通过蓝牙传递数据,但是我没有BLE设备。 我想使用常见的BLE特性来通过蓝牙传递数据。 有没有可用的模拟器? 我在哪里可以测试我的申请? 我正在Kotlin开发这个应用程序,请给我一个相应的解决方案。